DEV Community

Cover image for Design Pattern
AK
AK

Posted on

Design Pattern

What is a design pattern?

Design patterns are solutions to commonly occurring problems in software design. Design pattern is not code - rather, design patterns act as a guide or paradigm to help software engineers create products following best practices.


History of patterns

Design patterns are not obscure, sophisticated concepts - quite the opposite. Patterns are typical solutions to common problems in object-oriented design. When a solution gets repeated over and over in various projects, someone eventually puts a name to it and describes the solution in detail.

famous books

  1. A Pattern Language: Towns, Buildings, Construction (Center for Environmental Structure Series)
  2. Design Patterns: Elements of Reusable Object-Oriented Software

Why should learn patterns?

Design patterns are a toolkit of tried and tested solutions to common problems in software design.
Design patterns define a common language that you and your teammates can use to communicate more efficiently.

  1. Proven Solution
    Software developer does not have to reinvent the wheel when that problem occurs.

  2. Reusable
    Design patterns can be modified to solve many kinds of problems - they are not just tied to a single problem.

  3. Expressive
    Design patterns are an elegant solution.

  4. Prevent the need for refactoring code
    Since the design pattern is already the optimal solution for the problem, this can avoid refactoring.

  5. Lower the size of the codebase
    Each pattern helps software developers change how the system works without a full redesign. Further, as the "optimal" solution, the design pattern often requires less code.


Classification of patterns

Design patterns differ by their complexity, level of detail and scale of applicability to the entire system being designed. Design patterns can be broken down into 3 types.

  • Creational patterns provide object creation mechanisms that increase flexibility and reuse of existing code
  • Structural patterns explain how to assemble objects and classes into larger structure, while keeping structures flexible and efficient
  • Behavioral patterns take care of effective communication and the assignment of responsibilities between objects

Creational patterns

Structural patterns

  • Adapter
  • Bridge
  • Composite
  • Decorator
  • Facade
  • Flyweight
  • Proxy

Behavioral patterns

Top comments (0)