Introduction to Design Patterns

The idea of design patterns was introduced by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (Gang of Four). They distributed a book called “Design Pattern-Elements of Reusable Object-Oriented Software” in 1994 which prompted the development of design pattern ideas.

What is Design Pattern?

Designing object-oriented software is hard and designing reusable object-oriented software is even harder. To accomplish best practices in object-oriented programming, software engineers use Design Patterns. It is not a completed design that can be changed straightforwardly into code. It is a layout for how to tackle an issue that can be utilized in a wide range of circumstances. In the simplest way, we can describe design patterns as a common solution given for most of the problems which programmers faced during the development process. These solutions were acquired by experimentation by various programming engineers over a significant considerable period. According to the Gand of Four (Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides), design patterns are principally dependent on the accompanying standards of object-oriented design.

  • program to an interface, not an implementation.
  • favor object composition over inheritance.

According to the book called ‘Design Pattern-Elements of Reusable Object-Oriented Software’, Gang of Four has mentioned that in general, a pattern has 4 essential elements which are ‘The pattern name’, ‘The problem’, ‘The solution and ‘The consequences ’

Usage of Design Patterns

If we go through the main usage of the design patterns is to have a common way of implementing the flow of the program and also using these design patterns, a programmer has a chance to speed up the development process by giving tested, proven development paradigms. Most people just see how to apply specific programming design strategies to specific issues. These procedures are hard to apply to a more extensive scope of issues. design patterns give general solutions, reported in a layout/format that doesn’t need points of interest attached to a specific issue. Design patterns are reusable and it provides transparency to the application design and further, improve code readability. Consequently, learning these design patterns assists unpracticed programmers with building their code in a very much organized manner.

Types of Design Patterns

According to the book, ‘Design Pattern-Elements of Reusable Object-Oriented Software’ which was published by Gang of Four, design patterns are categorized into 3 different categories named as below.

  1. Creational Pattern
  2. Structural Pattern
  3. Behavioral Pattern

Creational Pattern — These design patterns are involved with the way of creating the objects. It allows creating objects without uncovering the creation logic therefore, we can give the type of object which we need and it will give us that object. Thus, it avoids instantiating objects straightforwardly, using the ‘new’ keyword. These creational design patterns provide more flexibility and increase the reusability of code.

examples:

  • Singleton Design Pattern
  • Factory Design Pattern
  • Abstract Factory Design Pattern
  • Builder Design Pattern
  • Prototype Design Pattern

Structural Pattern— These design patterns are involved to define the composition and structure of classes and objects and this uses the concept of inheritance for the procedure of composing interfaces and by using this type of design pattern, it helps to provide flexibility to classes and objects.

examples:

  • Adapter Design Pattern
  • Composite Design Pattern
  • Proxy Design Pattern
  • Fly Weight Design Pattern
  • Facade Design Pattern
  • Bridge Design Pattern
  • Decorator Design Pattern

Behavioral Pattern — This pattern is involved in communication (eg: how communication happens, when objects interact with each other), interaction and assignment of responsibilities between objects.

examples:

  • Template Design Pattern
  • MediatorDesign Pattern
  • Chain of Responsibility Design Pattern
  • Observer Design Pattern
  • Strategy Design Pattern
  • Command Design Pattern
  • State Design Pattern
  • Visitor Design Pattern
  • Iterator Design Pattern
  • Interpreter Design Pattern
  • Memento Design Pattern

From the upcoming stories, I will talk about some of the design patterns. GoodBye for now…..

--

--

--

Associate Engineer at Virtusa

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Making Your First Query with CockroachDB

Decorative puzzle pieces

Edit Clipboard History right in Paste

Reading Clean Code: Week 2

CS371p Fall 2021: Martin Nguyen

Friday Frontend: Thanksgiving edition

The journey From Question to Superhero at coding block

Live in the clouds

09/09New Azure Container Instance Vulnerability — What to do?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Roshni Silva

Roshni Silva

Associate Engineer at Virtusa

More from Medium

CS373 Spring 2022: Christopher Carrasco — Week 5

V. Ward Research Group: Sustainable Ways to Manufacture Petroleum-derived Materials & Environmental…

New Input System

CS373 Spring 2022: Shreya Sridhar