/Design-Patterns

All common design patterns in C++

Primary LanguageC++

Design Patterns C++

Software design patterns are a set of templates that are commanly seen in most of Object oriented projects. They are not complete solutions but are methods that can be applied to such problems which are common.

Creational

  1. Factory - Hides the creation of objects following a common interface.
  2. Abstract Factory - Add another layer of abstraction to Factory so that the factory can be subclassed.
  3. Builder - Hide the creation of complex objects which may involve a lot of steps for creation.
  4. Prototype - Create a clone of itself without explicitly knowing the class of the object.
  5. Singleton - Have single instance of a class in the entire application.

Structural

  1. Adapter - Make incompatible interfaces work together.
  2. Bridge - Provide two way abstraction for implementation of a stratergy and the class which uses such a stratergy.
  3. Composite - Provide a tree like structre for objects that follow a common interface.
  4. Decorator - Add new responsibilites to objects without subclassing.
  5. Facade - Encapsulate a group of interfaces in one to provide one call access to all of them.
  6. Flyweight - Store and reuse shared objects rather them creating them again and again.
  7. Proxy - Wrapp the real class around a proxy class to provide conditional ccess to the real object.

Behavioral

  1. Chain Of Responsibility - A chain of operations that is performed step by step if the pervious one cannot handle it.
  2. Command - Encapsulate a request so that it can be handled by diffrent classes that follow a common interface.
  3. Iterator - Provide a interface to access an aggregate class.
  4. Mediator - Provide a common point through all objects interact with each other.
  5. Memento - Store the previous states of the object and undo them when needed.
  6. Observer - Provide a one to many mode of communication between a subject and all its observers.
  7. Stratergy - Provide abstraction to variuous implementations of a particular stratergy.
  8. State - Provide a way to represent FSM.
  9. Template Method - Provide abstraction to the steps of an algorithm.
  10. Visitor - Allows operation to be performed on elemets of an object without changing those classes.