Advertisement

Introduction to Design Patterns

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


Creational Patterns
  1. Abstract Factory: Creates an instance of several families of classes.
  2. Builder: Separates object construction from its representation.
  3. Factory Method: Creates an instance of several derived classes.
  4. Prototype: A fully initialized instance to be copied or cloned.
  5. Singleton: A class of which only a single instance can exist.

 Structural Patterns
  1. Adapter: Match interfaces of different classes.
  2. Bridge: Separates an object’s interface from its implementation.
  3. Composite: A tree structure of simple and composite objects.
  4. Decorator: Add responsibilities to objects dynamically.
  5. Façade: A single class that represents an entire subsystem.
  6. Flyweight: A fine-grained instance used for efficient sharing.
  7. Proxy: An object representing another object.

Behavioral Patterns
  1. Chain of responsibility: A way of passing a request between a chain of objects.
  2. Command: Encapsulate a command request as an object.
  3. Interpreter: A way to include language elements in a program.
  4. Iterator: Sequentially access the elements of a collection.
  5. Mediator: Defines simplified communication between classes.
  6. Memento: Capture and restore an object's internal state.
  7. Observer: A way of notifying the change to a number of classes.
  8. State: Alter an object's behavior when its state changes.
  9. Strategy: Encapsulates an algorithm inside a class.
  10. Template method: Defer the exact steps of an algorithm to a subclass.
  11. Visitor: Defines a new operation to a class without change.

Goals of Design Patterns
  1. To support reuse, of
    • Successful designs.
    • Existing code !though less important".
  2. To facilitate software evolution
    • Add new features easily, without breaking existing ones.
  3. Design for change.
  4. Reduce implementation dependencies between elements of the software system.

Post a Comment

0 Comments