Last updated 2022-11-05 03:50:45

What Is A Design Pattern?

Table of contents


Design patterns represent best practices that experienced developers use to solve problems that frequently occur within software engineering. A design pattern explains the problem, its solution, when to use the solution, and the resulting consequences. The solutions that design patterns provide can be repeated whenever a problem of similar nature occurs.

Use Cases and Examples

Here are examples of design patterns:

  • Adapter pattern: This structural design pattern makes it possible to swap in and out for example third-party code [→] you depend on without having to make significant changes due to differences between the code, think of it like the outlet adapter you use when you travel. with such an adapter you won't need to change the wall outlet completely.
  • Singleton: is a good approach when you need to have just one instance of a class, this is useful when there are a number of processes to be performed to achieve a task, where each step affects the next.
  • Prototype: Sometimes you need more than an instance of some code (usually a class) for different purposes, a prototypal class acts like a template from which you create as many copies as you need.


Design patterns are defined as good programming practices that make the overall code effective and clean. A good design pattern provides a repeatable fix to a usual problem, thus ensuring a standardized ready-to-use solution. But like everything under the sun over time we discover better alternatives or these patterns become an anti-pattern [→].

Here is another article you might like 😊 "Diary Of Insights: A Documentation Of My Discoveries"