Wednesday, 11 January 2017

Design Patterns by Type

Let us try to understand Design Patterns by Type
Creational Patterns
Creational patterns provide a way to create objects while hiding the creation logic, rather than instantiating objects directly using new operator. This gives program more flexibility in deciding which objects need to be created for a given use case.
  • Abstract Factory Pattern : The abstract factory pattern provides a way for creating families of related or dependent objects without specifying their concrete classes.
  • Builder pattern Separate the construction of a complex object from its representation so that the same construction process can create different representations
  • Factory Method Pattern Define an interface for creating an object, but let subclasses decide which class to instantiate. The Factory method lets a class defer instantiation it uses to subclasses.
  • Prototype Pattern creates objects by cloning an existing object. Create new objects by copying this prototype.
  • Singleton Pattern restricts object creation for a class to only one instance. Ensure a class has only one instance, and provide a global point of access to it.
Structural Patterns
Structural Design Patterns are Design Patterns that ease the design by identifying a simple way to realize relationships between entities. They use inheritance to compose interfaces and define ways to compose objects to obtain new functionality.
  • Adapter Pattern allows classes with incompatible interfaces to work together by wrapping its own interface around that of an already existing class. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.
  • Bridge Pattern decouples an abstraction from its implementation so that the two can vary independently.
  • Composite Pattern composes zero-or-more similar objects so that they can be manipulated as one object.
  • Decorator Pattern dynamically adds/overrides behaviour in an existing method of an object.
  • Facade Pattern provides a simplified interface to a large body of code.
  • Flyweight Pattern reduces the cost of creating and manipulating a large number of similar objects.
  • Proxy Pattern provides a placeholder for another object to control access, reduce cost, and reduce complexity.
 Behavioral Pattern
These design patterns are specifically concerned with communication between objects
  • Chain of responsibility Pattern delegates commands to a chain of processing objects.
  • Command Pattern  creates objects which encapsulate actions and parameters.
  • Interpreter Pattern  implements a specialized language.
  • Iterator Pattern  accesses the elements of an object sequentially without exposing its underlying representation.
  • Mediator Pattern  allows loose coupling between classes by being the only class that has detailed knowledge of their methods.
  • Memento Pattern  provides the ability to restore an object to its previous state (undo).
  • Observer Pattern  is a publish/subscribe pattern which allows a number of observer objects to see an event.
  • State Pattern  allows an object to alter its behavior when its internal state changes.
  • Strategy Pattern  allows one of a family of algorithms to be selected on-the-fly at runtime.
  • Template Pattern  method defines the skeleton of an algorithm as an abstract class, allowing its subclasses to provide concrete behavior.
  • Visitor Pattern  separates an algorithm from an object structure by moving the hierarchy of methods into one object.
Design Pattern By Types
Design Patterns By Types


No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...