how many types of design patterns are there

How Many Types of Design Patterns Are There? A Complete Guide

By Matthew Brown
AD

Design patterns are reusable solutions to common problems in software design. They are not finished designs that can be transformed directly into code, but rather descriptions of how to solve problems that arise in particular contexts. The Gang of Four (GoF) book, "Design Patterns: Elements of Reusable Object-Oriented Software," introduced 23 classic design patterns, which are categorized into three groups: creational, structural, and behavioral. However, the number of design patterns has grown beyond these 23, with various other patterns introduced over the years. Let's delve into the different types of design patterns, their categorizations, and some examples.

Categorization of Design Patterns

The categorization of design patterns helps in understanding their purpose and when to apply them. The most well-known categorization is the one proposed by the GoF, which includes:

  • Creational Patterns: These patterns provide mechanisms for creating objects in such a way as to increase flexibility and reuse of existing code. Examples include Singleton, Factory Method, Abstract Factory, Builder, and Prototype.
  • Structural Patterns: These patterns deal with the composition of classes or objects. They provide ways to compose objects into larger structures while keeping these structures efficient. Examples include Adapter, Bridge, Composite, Decorator, Faรงade, Flyweight, and Proxy.
  • Behavioral Patterns: These patterns define communication patterns between objects and describe how objects interact with each other. Examples include Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, and Visitor.

Other categorizations exist as well, such as the one proposed by the Portland Pattern Repository, which includes additional patterns and categorizes them into:

AD
These 22 System Design patterns cover 90% of the interviews youโ€™ll ever face ๐Ÿ‘‡ | Rajat Gajbhiye | 28 comments
These 22 System Design patterns cover 90% of the interviews youโ€™ll ever face ๐Ÿ‘‡ | Rajat Gajbhiye | 28 comments
Nelson Djalo | Amigoscode (@AmigosCode) on X
Nelson Djalo | Amigoscode (@AmigosCode) on X
Dr Milan Milanoviฤ‡ (@milan_milanovic) on X
Dr Milan Milanoviฤ‡ (@milan_milanovic) on X
  • Creational
  • Structural
  • Behavioral
  • Multitier
  • Concurrency
  • Data Access
  • Web

Beyond the GoF Patterns: Additional Design Patterns

Since the publication of the GoF book, many other design patterns have been introduced to address specific problems or improve upon existing patterns. Some of these additional patterns include:

  • Null Object: Provides a default implementation of a class, avoiding the use of null values.
  • Specification: Defines a set of tests that an object must pass to be considered valid.
  • Interpreter: Provides a way to evaluate language grammar or expressions.
  • Bridge: Decouples an abstraction from its implementation so that they can vary independently.
  • Composite: Allows clients to compose objects into tree structures to represent hierarchic structures.
  • Decorator: Attaches additional responsibilities to an object dynamically. Provides a flexible alternative to subclassing for extended functionality.

Design Patterns in Different Languages and Paradigms

While design patterns were initially introduced for object-oriented programming (OOP), they can also be applied to other programming languages and paradigms. Some examples include:

JavaScript Design Patterns: A Complete Guide With Best Practice | TestMu AI (Formerly LambdaTest)
JavaScript Design Patterns: A Complete Guide With Best Practice | TestMu AI (Formerly LambdaTest)
Pattern in Design | Principle of Design Explained with Examples
Pattern in Design | Principle of Design Explained with Examples
an info sheet with different types of patterns and words on it, including the names
an info sheet with different types of patterns and words on it, including the names
  • Functional Programming: Patterns like Monad, Functor, and Applicative are used to handle side effects, data manipulation, and functional composition.
  • JavaScript: Patterns like Module, Observer, and Mediator are used to manage code organization, data synchronization, and object interaction.
  • Python: Patterns like Singleton, Factory, and Decorator are used to control object creation, configuration, and behavior modification.

Table: Design Patterns and Their Categorizations

Pattern Categorization (GoF) Categorization (Portland)
Singleton Creational Creational
Factory Method Creational Creational
Adapter Structural Structural
Command Behavioral Behavioral
Null Object Creational Creational
Specification Behavioral Behavioral

In conclusion, the number of design patterns has grown beyond the initial 23 GoF patterns, with various categorizations and additional patterns introduced over the years. Understanding these patterns and their categorizations can help software developers create more flexible, maintainable, and reusable code, regardless of the programming language or paradigm used.

the different types of wood flooring patterns and their names in english, french or japanese
the different types of wood flooring patterns and their names in english, french or japanese
a guide to patterns for quilts
a guide to patterns for quilts
Junior developer needs to know 4 patterns Middle dev needs to know 12 patterns Senior developer needs to know 20 patterns Design patterns help you solve common problems and improve code quality ifโ€ฆ | Anton Martyniuk | 52 comments
Junior developer needs to know 4 patterns Middle dev needs to know 12 patterns Senior developer needs to know 20 patterns Design patterns help you solve common problems and improve code quality ifโ€ฆ | Anton Martyniuk | 52 comments
an info sheet with different patterns and colors on it, including the text that says 5 trending patterns
an info sheet with different patterns and colors on it, including the text that says 5 trending patterns
If you write code, you should read this. ๐–๐ก๐ฒ ๐ƒ๐ž๐ฌ๐ข๐ ๐งโ€ฆ | Mayank Ahuja | 29 comments
If you write code, you should read this. ๐–๐ก๐ฒ ๐ƒ๐ž๐ฌ๐ข๐ ๐งโ€ฆ | Mayank Ahuja | 29 comments
Pattern choices
Pattern choices
some type of fabric that looks like different patterns
some type of fabric that looks like different patterns
41 Insanely Helpful Style Charts Every Woman Needs Right Now
41 Insanely Helpful Style Charts Every Woman Needs Right Now
a guide to patterns in black and white
a guide to patterns in black and white
the ultimate flower patterns vocabulary poster is shown in pink, purple and white
the ultimate flower patterns vocabulary poster is shown in pink, purple and white
the different types of patterns in blue and white
the different types of patterns in blue and white
the different patterns and colors of fabric
the different patterns and colors of fabric
an info poster showing the different types of patterns
an info poster showing the different types of patterns
many different patterns and colors in the style of art deco, including red, green, blue
many different patterns and colors in the style of art deco, including red, green, blue
the different types of designers are shown in this poster
the different types of designers are shown in this poster
an info sheet with different types of patterns and text on it, including the words'objects
an info sheet with different types of patterns and text on it, including the words'objects
50+ Amazing Geometric Design Patterns
50+ Amazing Geometric Design Patterns
cute patterns! ๐ŸŽน ๐ŸฆŒ
cute patterns! ๐ŸŽน ๐ŸฆŒ
50 Geometric Seamless Patterns by Creators Club | Creative Market
50 Geometric Seamless Patterns by Creators Club | Creative Market
AD