WIPIVERSE All articles

Design pattern

A design pattern is a general, reusable solution to a commonly occurring problem within a given context in software engineering. It is not a finished piece of code, but rather a description or template for how to solve a problem that can be adapted to specific situations.

Origin and development
The concept originated in the field of architecture with architect Christopher Alexander, who catalogued recurring design solutions in his 1977 book A Pattern Language. The idea was transferred to software engineering by members of the "Gang of Four"—Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides—who published Design Patterns: Elements of Reusable Object‑Oriented Software in 1994. Their work identified 23 classic object‑oriented patterns and established a common vocabulary for discussing software design.

Classification
Design patterns are commonly grouped into three categories:

Category Purpose Typical examples
Creational Manage object creation mechanisms, trying to create objects in a manner suitable to the situation. Singleton, Factory Method, Abstract Factory, Builder, Prototype
Structural Describe how classes and objects can be composed to form larger structures. Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy
Behavioral Focus on communication between objects. Observer, Strategy, Command, Iterator, Mediator, Memento, State, Template Method, Visitor

Characteristics

  • Abstraction: Patterns describe the problem and solution at a high level of abstraction.
  • Context: Each pattern specifies the circumstances under which it is applicable.
  • Consequences: Patterns discuss trade‑offs, benefits, and potential drawbacks.
  • Documentation: Standard pattern documentation includes name, intent, motivation, applicability, structure (often shown with UML diagrams), participants, collaborations, implementation, and known uses.

Usage
Design patterns serve several purposes in software development:

  1. Communication: Provide a shared vocabulary that allows developers to discuss design decisions succinctly.
  2. Best practices: Encode proven solutions, reducing the risk of reinventing flawed designs.
  3. Maintainability: Encourage modular, loosely coupled structures that are easier to extend and refactor.

Criticism and limitations
While widely adopted, design patterns have been critiqued for:

  • Potential overuse, leading to unnecessary complexity (sometimes called “pattern fever”).
  • Being less relevant in languages that provide built‑in constructs (e.g., closures, mixins) that accomplish similar goals more directly.
  • The risk of “pattern‑driven” designs that prioritize pattern compliance over pragmatic solutions.

Related concepts

  • Architectural pattern: Higher‑level patterns that address system‑wide organization (e.g., Model‑View‑Controller, Microservices).
  • Anti‑pattern: Common responses to a problem that are ineffective or counterproductive.
  • Idioms: Language‑specific conventions that solve recurring problems without the formal structure of a pattern.

References

  • Gamma, E.; Helm, R.; Johnson, R.; Vlissides, J. (1994). Design Patterns: Elements of Reusable Object‑Oriented Software. Addison‑Wesley.
  • Alexander, C. (1977). A Pattern Language: Towns, Buildings, Construction. Oxford University Press.
  • Freeman, E.; Robson, E. (2004). Head First Design Patterns. O'Reilly Media.

Design patterns remain a foundational concept in software engineering education and practice, providing a systematic approach to solving recurring design challenges.

Browse

More topics to explore

    Browse all articles