-
Patterns show you how to build systems with good OO desing qualities.
-
Good OO desings are reusable, extensible and maintainable.
-
When you see new, think concrete. Tying your code to a concrete class can make it more fragile and less flexible. The real culprit is our old friend CHANGE and how change impacts our use of new.
-
Don't forget, we are also just about to remove the concrete instantiations from our client code!
The Strategy Pattern defines family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
The Singleton Pattern ensures a class has only one instance, and provides a global point of access to it. The classic implementation doesn't handle multi-threading.
Factories handle the details of object creation.
As with every factory, the Factory Method Pattern gives us a way to encapsulate the instantiations of concrete types.