Posts tagged “Patterns”

Replacing constructors with factory methods
Simply put, a factory method is any method that encapsulates the logic of how instances of a particular class are created. Considering this loose definition, it might seem at first that to a large extent factory methods are little, if any, different from plain old class constructors. As we shall see however, they are a more powerful option that can help us write cleaner and more maintainable code.
Read more