Design Patterns
In 1994, Four authors Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides published a book titled “Design Patterns - Elements of Reusable Object-Oriented Software” which initiated the concept of Design Pattern in Software development.
These authors are collectively known as Gang of Four (GoF). According to these authors, design patterns are primarily based on the following principles of object orientated design.
- Program to an interface, not an implementation
- Favor object composition over inheritance
Types of Design Patterns
There are 23 design patterns which can be classified into three categories: Creational, Structural and Behavioral patterns.
- Creational Patterns: These design patterns are all about class instantiation.
- Structural Patterns: These design patterns concern class and object composition. The concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities.
- Behavioral Patterns: These design patterns are specifically concerned with communication between objects.
- J2EE Patterns: These design patterns are specifically concerned with the presentation tier. These patterns are identified by Sun Java Center.
Creational Patterns
|
Structural Patterns
|
Behavioral Patterns
|
1. Abstract Factory
2. Builder
3. Factory Method
4. Prototype
5. Singleton
|
1. Adapter
2. Bridge
3. Composite
4. Decorator
5. Façade
6. Flyweight
7. Proxy
|
1. Chain of responsibility
2. Command
3. Interpreter
4. Iterator
5. Mediator
6. Memento
7. Observer
8. State
9. Strategy
10. Template method
11. Visitor
|
- Abstract Factory: Creates an instance of several families of classes.
- Builder: Separates object construction from its representation.
- Factory Method: Creates an instance of several derived classes.
- Prototype: A fully initialized instance to be copied or cloned.
- Singleton: A class of which only a single instance can exist.
Structural Patterns
- Adapter: Match interfaces of different classes.
- Bridge: Separates an object’s interface from its implementation.
- Composite: A tree structure of simple and composite objects.
- Decorator: Add responsibilities to objects dynamically.
- Façade: A single class that represents an entire subsystem.
- Flyweight: A fine-grained instance used for efficient sharing.
- Proxy: An object representing another object.
Behavioral Patterns
- Chain of responsibility: A way of passing a request between a chain of objects.
- Command: Encapsulate a command request as an object.
- Interpreter: A way to include language elements in a program.
- Iterator: Sequentially access the elements of a collection.
- Mediator: Defines simplified communication between classes.
- Memento: Capture and restore an object's internal state.
- Observer: A way of notifying the change to a number of classes.
- State: Alter an object's behavior when its state changes.
- Strategy: Encapsulates an algorithm inside a class.
- Template method: Defer the exact steps of an algorithm to a subclass.
- Visitor: Defines a new operation to a class without change.
Goals of Design Patterns
- To support reuse, of
- Successful designs.
- Existing code !though less important".
- To facilitate software evolution
- Add new features easily, without breaking existing ones.
- Design for change.
- Reduce implementation dependencies between elements of the software system.
0 Comments