Design Patterns | Introduction

Raman Bhadauria
2 min readFeb 10, 2022

--

Being a Software Developer, whenever we build any application, broadly we face two kind of problems: (a) domain-specific problem and (b) common software design problems. Domain-specific problems means problems specific to the problem statement and domain of the application we are building e.g. we are building a banking application then our main focus will be security and if we are building a chatting application our main focus will be easy-to-use and instantaneous messaging. On the other hand, common software design problems refers to the problems which are faced by everyone irrespective of the application and language. For example a common object oriented problem can be creating a class of which only single instance can be created. That’s a common problem and once found a solution of it, can be used everywhere as the solutions are of conceptual nature and can be applied anywhere irrespective of the programming language. For such common object oriented problems, we have a well established solutions now that we call Design Patterns.

Design patterns are well established and proven solutions for solving common object oriented design problems. These are just strategies/ideas and not a particular implementation.

Why should we use Design Patterns?

  • It makes our code structured, flexible, reusable and maintainable.
  • It provides solutions to the common object oriented design problems and can be used in multiple projects depending upon the use cases.
  • It is well established and proven solutions backed by year of experience of software development.
  • It can be used easily as a programming vocabulary in the discussion among developers so that they can focus on main business logic instead of explaining recurring design problem’s solutions over and over again which can be misunderstood.

GoF Design Patterns

  • The Gang of Four — Design patterns, elements of reusable object-oriented software book was written by a group of four persons named as Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides in 1995.
  • That’s why the most common and popular 23 Design Patterns are known as Gang of Four (GoF) Design Patterns.

Types of Design Patterns

Creational Design Patterns

It deals with the creation of objects.

  1. Singleton
  2. Factory
  3. Builder
  4. Abstract Factory
  5. Prototype

Structural Design Patterns

It deals with the inheritance, composition and relationship between classes and objects.

  1. Adapter
  2. Composite
  3. Façade
  4. Decorator
  5. Proxy
  6. Bridge
  7. Fly Weight

Behavioral Design Patterns

It deals with the interaction of the objects in such a way that the interaction between the objects is effective but still loosely coupled with each other and flexible enough to be extended.

  1. Template Method
  2. Mediator
  3. Chain of Responsibility
  4. Observer
  5. Strategy
  6. Command
  7. State
  8. Visitor
  9. Iterator
  10. Interpreter
  11. Memento

--

--