DEV Community

Cover image for DESIGN PATTERNS
Hari Krishnan
Hari Krishnan

Posted on • Updated on

DESIGN PATTERNS

What are design patterns ?

Software development is an iterative process and there may be many design problems during development. Design patterns are the solution to software design problems which every developer faces very frequently. Patterns are simply reusable designs.

Types of design patterns

There are three different types of design patterns :

  1. Creational
  2. Structural
  3. Behavioural

Creational Patterns

These patterns are used for instantiation of classes. They are concerned with the way of creating objects. Normally object creation happens in the below way by using the new keyword.

Employee emp = new Employee();
Enter fullscreen mode Exit fullscreen mode

The above code is more than enough for object instantiation, but in some cases the object must be changed according to the nature of the program in runtime, in such cases, creational design patterns will be useful.

  • Abstract Factory
  • Builder
  • Factory Method
  • Prototype
  • Singleton

Structural Patterns

Structural design patterns are concerned with how objects and classes are composed. This pattern helps in simplifying the structure by identifying the relationships. It focuses on how classes inherit from each other and how they are composed from other classes.

The main goal is to increase or extend the functionalities of the class without changing its composition.

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

Behavioural Patterns

These patterns are designed depending on how one class communicates with other. Interaction between classes should be in such a way that they should easily communicate with each other; still thee classes would be loosely coupled.

  • Chain of Responsibilities
  • Command
  • Interpreter
  • Iterator
  • Mediator
  • Memento
  • Observer
  • State
  • Strategy
  • Template Method
  • Visitor

OTHER TERMS TO KNOW

What is an abstract class ?

Abstract class means hiding the implementation and just showing the function definition to the user. Abstract classes cannot be instantiated, it should be inherited and then instantiation should be done for the subclass. It can have both abstract and non-abstract methods.

What is a concrete class ?

A concrete class is a class which has implementation for all of its methods. It cannot have any unimplemented methods. It is simply the sub class which is inherited from an abstract class.

Alt Text

Top comments (0)