New answers tagged

2

You haven't achieved anything with your redesign, the Investigation module is still transitively dependent on CheckImplementations module. To properly achieve the decoupling of your Investigation and CheckImplementation modules, it would be necessary to create ICheckFactory interface, so that dependency between Investigation and CheckFactory is inverted, eg. ...


2

In trying to adhere to some acronym, you are overengineering your solution. The steps you mention are excellent candidates to be (private) methods in a class, with the method you have now for composing and iterating over the list of abstract Step classes calling those step methods instead. As the step-methods don't need to have all the same signature, you ...


3

LSP means that if you have an instance of a subclass, it can be used in place of an instance of the base class. Creating an instance of a subclass is not subject to LSP, since there is no complete instance yet. Thus, LSP only means the instances must be substitutable. The classes do no have this restriction.


5

Your gut is right, that's sub-optimal for an object-oriented design. What you're doing is basically having a procedural decomposition, that is, you are thinking about the technical steps needed to make your code work. You even created an abstraction over basically a generic procedure and called it IStep. This is unfortunately a completely natural way to ...


8

As an outside consumer, there is no way to rely on a base class' constructor when initializing a subclass. The initialization of the subclass is the subclass' responsibility and no one else's. The subclass' constructor can fall back on its ancestor's constructor (I assume this applies to all languages), but that is a free choice (it can pick any base ...


7

No. LSP does not consider the creation of instances because you need to know the exact class you are instantiating anyway.


8

There is nothing wrong per se with a class BusinessLogic which orchestrates the logic of calling methods of a huge list of other objects, as long as one does not mix up different levels of abstraction. When BusinessLogic only connects the data flow between objects like dataSender, validator, dataPersister, feeCalculator, anotherDataSender, ..., it does ...


0

Presumably not everything that relies on business logic, must have or even need access to all of the functions in this class. Why not look for a natural cleave point? A good cleave would be one that reduces the amount of users needing both halves, or where the implementation doesn't need the other half of the class to achieve its goal. Another trick would ...


Top 50 recent answers are included