http://18delphi.blogspot.com/2015/02/briefly-about-factories.html

http://18delphi.blogspot.com/2015/02/briefly-about-factories.html

Comments

  1. SRP: A factory should not belong into the class it's a factory for - especially not when possibly also creating couple other classes

    Coupling: Making the factory method a non virtual class function will have the same static binding as calling the constructor. Knowing the classes to create in the base class factory method also couples the base class to their child classes.

    Testability: Hiding classes in the implementation section seem clever first but it avoids testing these classes in isolation - for testing they should not be retrieved through the factory because that involves code in the test that is not subject of the test.

    ReplyDelete
  2. SRP
    besides it we have KISS, YAGNI and Occam's razor

    ReplyDelete

Post a Comment