Learning about different kind of design pattern in Java OOPS. Implementing various examples to get most of it.
Questions have been taken from Head First Design Book
- Each design pattern contains a related question and it's definitions and implementation.
- Identify the aspects of your application that vary and separate them from what stays the same.
- Program to an interface, not an implementation. Program to an interface means designing code to depend on abstract types (interfaces or abstract classes) rather than concrete implementations.
- Favor composition over inheritance.
- Strive for loosely coupled designs between objects that interact.
- Classes should be open for extension, but closed for modification.
Focus on object creation mechanisms, trying to create objects in a manner suitable for the situation.
Example: Factory Method, Abstract Factory, Singleton. Key Idea: Encapsulate object creation to promote flexibility.
Deal with the composition of classes or objects to form larger structures.
Example: Adapter, Composite, Decorator. Key Idea: Simplify relationships between entities or extend functionality dynamically.
Concerned with algorithms and communication between objects.
Example: Strategy, Observer, Command. Key Idea: Define communication and responsibilities between objects.