While working on software design for real-world applications, we often need help with common situations and encounter recurring problems. Design patterns provide solutions or general concepts for solving these recurring problems. There are no common templates for design patterns, but you can follow the concept and implement a solution for your situation.

History of Design Patterns

Christopher Alexander, an architect, first discussed patterns in A Pattern Language: Towns, Buildings, Construction. The book described common design principles for various aspects of urban environment and development.

Four authors, Erich Gamma, John Vlissides, Ralph Johnson, and Richard Helm picked the idea in the early 1990s. They published a book Design Patterns: Elements of Reusable Object-Oriented Software which talked about the concepts of design patterns in programming. This book was later known as “The Gang of Four Book”!

Classification of Patterns

The Gang of Four categorized design patterns into three categories. These are:

  • Creational Patterns: describes how to create objects, improves flexibility, and promotes code reuse
  • Structural Patterns: describes how different types of objects can be used together while maintaining flexibility and reusability
  • Behavioral Patterns: describes how to organize, combine, and manage object behavior
Creational Patterns Structural Patterns Behavioral Patterns
Abstract Factory Adapter Chain of Responsibility
Builder Bridge Command
Factory Method Composite Iterator
Prototype Decorator Mediator
Singleton Facade Memento
  Flyweight Observer
  Proxy State
    Strategy
    Template Method
    Visitor

You can find all the code examples in the posts here !