What is Design Pattern ?
- Design Patterns are all about resusing experience.
- A design pattern is an approach to thinking about software design that incorporates the experience of developers who've had similar problems.
- A design pattern is usually expressed by a defination and a class diagram.
- Program to an interface not an implementation [p-1]
- Favor object composition over inheritance [p-2]
- Encapsulate what varies [p-3]
- Single Responsibility [p-4]
- The open - closed principle [p-5] -- open for extension -- close for modification
- Loose coupling [p-6]
Strategy Pattern [p-1]:
Adapter Pattern:
Observer Pattern:
Decorator Pattern:
Factory Pattern:
- Head First Design Patterns
- By Eric Freeman & Elisabeth Robson & Bert Bates & Kathy Sierra
- Design Patterns Elements of Reusable Object-Oriented Software
- By Erich Gamma, John Vlissides, Ralph Johnson, and Richard Helm