The Gang of Four (GoF) design patterns are a collection of 23 classic software design patterns first described in the 1994 book "Design Patterns: Elements of Reusable Object-Oriented Software" by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (hence the name "Gang of Four").
The patterns are divided into three main categories:
Deal with object creation mechanisms, trying to create objects in a manner suitable to the situation.
Concerned with how classes and objects are composed to form larger structures.
Characterize the ways in which classes or objects interact and distribute responsibility.
Provides an interface for creating families of related or dependent objects without specifying their concrete classes.
Separates the construction of a complex object from its representation.
Defines an interface for creating an object, but lets subclasses decide which class to instantiate.
Specifies the kinds of objects to create using a prototypical instance, and creates new objects by copying this prototype.
Ensures a class has only one instance, and provides a global point of access to it.
Converts the interface of a class into another interface clients expect.
Decouples an abstraction from its implementation so that the two can vary independently.
Composes objects into tree structures to represent part-whole hierarchies.
Attaches additional responsibilities to an object dynamically.
Provides a unified interface to a set of interfaces in a subsystem.
Uses sharing to support large numbers of fine-grained objects efficiently.
Provides a surrogate or placeholder for another object to control access to it.
Aviods coupling the sender of a request to its receiver by giving more than one object a chance to handle the request.
Encapsulates a request as an object, thereby letting you parameterize clients with different requests.
Given a language, defines a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.
Provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation.
Defines an object that encapsulates how a set of objects interact.
Without violating encapsulation, captures and externalizes an object's internal state so that the object can be restored to this state later.
Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
Allows an object to alter its behavior when its internal state changes.
Defines a family of algorithms, encapsulates each one, and makes them interchangeable.
Defines the skeleton of an algorithm in an operation, deferring some steps to subclasses.
Represents an operation to be performed on the elements of an object structure.
While powerful, design patterns should not be overused. Considerations include:
The GoF design patterns remain foundational knowledge for software developers, providing a toolkit for solving common design problems in object-oriented systems.
Comments - Beta - WIP