The numbers of design patterns are less than English alphabets. Twenty-three design patterns are featured in the GoF design patterns book, falling within one of three subgroups: Creational, Structural, or Behavioral.
Creational
Creational patterns deal with object construction and referencing. They abstract away the responsibility of instantiating instances of objects from the client, thus keeping code loosely coupled and the responsibility of creating complex objects in one place adhering to the Single Responsibility and Separation of Concerns principles.
Following are the patterns in the Creational group:
➤➤ Abstract Factory: Provides an interface to create families of related objects.
➤➤ Factory: Enables a class to delegate the responsibility of creating a valid object.
➤➤ Builder: Enables various versions of an object to be constructed by separating the construction for the object itself.
➤➤ Prototype: Allows classes to be copied or cloned from a prototype instance rather than creating new instances.
➤➤ Singleton: Enables a class to be instantiated once with a single global point of access to it.
Structural
Structural patterns deal with the composition and relationships of objects to fulfill the needs of Larger systems.
Following are the patterns in the Structural group:
➤➤ Adapter: Enables classes of incompatible interfaces to be used together.
➤➤ Bridge: Separates an abstraction from its implementation, allowing implementations andabstractions to vary independently of one another.
➤➤ Composite: Allows a group of objects representing hierarchies to be treated in the same way as a single instance of an object.
➤➤ Decorator: Can dynamically surround a class and extend its behavior.
➤➤ Facade: Provides a simple interface and controls access to a series of complicated interfaces and subsystems.
➤➤ Flyweight: Provides a way to share data among many small classes in an efficient manner.
➤➤ Proxy: Provides a placeholder to a more complex class that is costly to instantiate.
Behavioral
Behavioral patterns deal with the communication between objects in terms of responsibility and algorithms. The patterns in this group encapsulate complex behavior and abstract it away from the flow of control of a system, thus enabling complex systems to be easily understood and maintained.
Following are the patterns in the Behavioral group:
➤➤ Chain of Responsibility: Allows commands to be chained together dynamically to handle arequest.
➤➤ Command: Encapsulates a method as an object and separates the execution of a command from its invoker.
➤➤ Interpreter: Specifies how to evaluate sentences in a language.
➤➤ Iterator: Provides a way to navigate a collection in a formalized manner.
➤➤ Mediator: Defines an object that allows communication between two other objects without them knowing about one another.
➤➤ Memento: Allows you to restore an object to its previous state.
➤➤ Observer: Defines the way one or more classes can be alerted to a change in another class.
➤➤ State: Allows an object to alter its behavior by delegating to a separate and changeable state object.
➤➤ Strategy: Enables an algorithm to be encapsulated within a class and switched at run time to alter an object’s behavior.
➤➤ Template Method: Defines the control of flow of an algorithm but allows subclasses to override or implement execution steps.
➤➤ Visitor: Enables new functionality to be performed on a class without affecting its structure.