Design Patterns Introduction


Creational Patterns

Creational patterns instantiate Group of similar objects or Single object. 
There are five creational patterns:
  • Abstract Factory: It creates family of related or dependent object.
  • Builder. It is used to create complicated objects with the parts of class that required to be created in the some fix order or with specific algorithm style. External class controls the creation of object.
  • Factory Method. This patter abstracting the process of object construction. It is used to create a object of particular class at runtime by delegating the responsibility of object creation to subclass. 
  • Prototype. It is used to create a new object with copying all of the properties of an existing object, creates an independent clone object. 
  • Singleton. It ensures that only one and only one object of a class is ever getting created. All references to objects of the class refer to the same created instance.

Structural Patterns

Structural patterns defines relations between classes or objects.
  • Adapter: It is used to provide a link or relation between two incompatible types by wrapping the "adaptee" by a class which supports the interface required by the end client.
  • Bridge: It is used to separate the abstract members of a class from the details of implementation, It provides the means to replace the implementation details without modifying the abstraction.
  • Composite: It is used to create recursive, hierarchical, tree type structures of family of related objects where any member of the structure can be accessed and used in a proper manner.
  • Decorator: It is used to alter or extend the behavior or functionality of objects at runtime by wrapping them in decorator class object. It provides a flexible alternative to inheritance to modify objects behaviour.
  • Facade. It is used to define a simple easy interface to a more complex sub-system.
  • Flyweight: It is used to decrease the memory and resource use for complicated models contains many more of similar objects.
  • Proxy: It is used to provide a placeholder or surrogate object, It references an underlying object. This pattern provides the same public interface as the underlying subject class, It adds one level of indirection by accepting client objects request and passing the request to the real object as required.

Behavioural Patterns

Behavioural patterns define communications manner among classes and objects.
  • Chain of Responsibility. It is used to process requests, each request  may be dealt a different handler.
  • Command: It is used to express a request, It make the call with all required parameters in the command object. The command then executed immediately or may be later.
  • Interpreter: It is used to define the grammar to understand the instructions and that form the part of a language, and also allow the grammar to be easily extended.
  • Iterator: It is used to provide a standard interface for iterating a collection of items in an object without the understand of it underlying structure.
  • Mediator: It is used to reduce classes coupling that communicate with each other. Classes doesn't communicate directly but classes send messages via a the mediator object.
  • Memento: It is used to capture the present state of an object and store it in so, that it can be restored later time without breaching rules of encapsulation.
  • Observer: This pattern allows an object to publish the changes in its state. Other objects which are subscribed are immediately notified for the changes.
  • State: It is used to alter the object's behaviour based on its internal state changes. This pattern allows the class for an object to be change at runtime.
  • Strategy: It is used to create family of algorithms that can be interchange at run-time.
  • Template Method: It is used to define the steps of an algorithm and it allow the implementation of the any step to be changed.
  • Visitor: It is used to separate a family of complex set of structured  classes from the functionality that will be performed upon the data they hold.