What is a design pattern?

What is a design pattern?



Information drawn from

We write code to solve problems. These problems usually have many similarities, and, when trying to solve them, we notice several common patterns. This is where design patterns come in.

A design pattern is a term used in software engineering for a general, reusable solution to a commonly occurring problem in software design.

Design patterns are by no means finished solutions. They only provide us with approaches or schemes to solve a problem. The underlying concept of design patterns has been around in the software engineering industry since the very beginning, but they weren’t really so formalised.

Design patterns are beneficial for various reasons. They are proven solutions that industry veterans have tried and tested. They are solid approaches that solve issues in a widely accepted way and reflect the experience and insights of the industry-leading developers that helped define them. Patterns also make your code more reusable and readable while speeding up the development process vastly.

Design Patterns: Elements of Reusable Object-Oriented Software (1994) is a software engineering book describing software design patterns. The book was written by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides, with a foreword by Grady Booch. The book is divided into two parts, with the first two chapters exploring the capabilities and pitfalls of object-oriented programming, and the remaining chapters describing 23 classic software design patterns. The book includes examples in C++ and Smalltalk.

Categories of Design Patterns

Design patterns are usually categorized into three major groups.

Creational Design Patterns

As the name suggests, these patterns are for handling object creational mechanisms. A creational design pattern basically solves a problem by controlling the creation process of an object. Includes: Constructor Pattern, Factory Pattern, Prototype Pattern, and Singleton Pattern.

Structural Design Patterns

These patterns are concerned with class and object composition. They help structure or restructure one or more parts without affecting the entire system. In other words, they help obtain new functionalities without tampering with the existing ones. Includes: Adapter Pattern, Composite Pattern, Decorator Pattern, Façade Pattern, Flyweight Pattern, and Proxy Pattern.

Behavioral Design Patterns

These patterns are concerned with improving communication between dissimilar objects. Includes: Chain of Responsibility Pattern, Command Pattern, Iterator Pattern, Mediator Pattern, Observer Pattern, State Pattern, Strategy Pattern, and Template Pattern.

------------------------------------------------------------------------

Last update on 24 Feb 2020

---