5 votes

Newbie: OOP working with different class-datatypes and loop through them

Your named objects either need Inherits abstractClass or Implements interfaceclass.name Make whichever one you pick and give it a Name method with no implementation. Then main needs either Private ...
4 votes

How can I prevent an object from being re-sanitized everytime it is passed as input to a function?

You seem to suggest that at the same time: You intentionally want an input CharStream to remain the same reference so that it can be modified by reference and have those changes available to your ...
  • 40.6k
3 votes
Accepted

Creating an abstraction just for exception handling - a pattern or anti-pattern?

This example of routing all exceptions to a log does not show an anti-pattern, quite the opposite, it is an example for a well-known GoF pattern - the Template Method pattern. ...
  • 194k
2 votes
Accepted

Pattern for a base class to do pre-validation and/or post-processing on a deriving class's overridden method?

It's a variation of the template method pattern. AbstractClass { void method() { methodImpl(); } abstract void methodImpl(); } ConcreteClass extends AbstractClass { void ...
  • 353
2 votes

Efficient way to Decouple classes in class design

Let me start off by saying that as in most cases with software engineering, there are probably many possible solutions. Since you are a beginner, I also want to give you some general advice. Favor ...
  • 353
1 vote
Accepted

Avoid use of the visitor pattern in this very common scenario

The problem with this architecture is that when we implement a new sender service we are also forced to modify the MessageDispatcher. This is arguably a good thing, since the compiler will force you ...
  • 3,159
1 vote

Pattern for a base class to do pre-validation and/or post-processing on a deriving class's overridden method?

Is there a better way to accomplish this behaviour? They say favor composition over inheritance. A pattern that might give you more flexibility and still do everything you're doing here is the ...
1 vote

Why do we separate interface when implementing interface injection variant of DI?

For reference, in case Wikipedia gets edited, the example given is this: public interface ServiceSetter { public void setService(Service service); } public class Client implements ServiceSetter { ...
  • 40.6k
1 vote

Are arrays -as data structures- suitable for constructors?

Arrays are used to hold multiple interchangeable entities. They don’t need any ordering, but usually can be sorted. You are storing three parameters. They have the same type, but that is purely ...
  • 40.5k

Only top scored, non community-wiki answers of a minimum length are eligible