Classification of Design Patterns
Source: Medium.com

Classification of Design Patterns

# You can read about the difference between design patterns and principle from here.

Story:

When we want to do big things then we need to maintain 3 major points. Like:

  1. Creating its smallest parts
  2. Structure them properly
  3. Controlling their behaviors

So it's really important to look after all these 3 points for obtaining a maintainable big system. Because unnecessary more things creation than needed, unstructured the smallest parts of the system and not proper controlling their behaviors can easily break the whole system.

Design Pattern:

In short, Design Pattern provides low-level solutions related to implementation of commonly occurring object-oriented problems. In other words, the design pattern suggests a specific implementation for the specific object-oriented programming problem.?That is design pattern gives us a solution with implementation guideline of commonly occurs object oriented problems when we creating software.

Classification of Design Patterns:

Depends on the problem and solution domains, design patterns they can be classified into 3 types: They are:

No alt text provided for this image
Source: javaScript.plainenglish.io

1. Creational Design Patterns:

As it name refers, this type of design patterns is concern about the creation of objects. Means creational design patterns gives as a implementational guideline for how objects can be created efficiently and with a extendable procedure. This type of design patterns describe the scenario when and how objects can be created without memory leak and increased the flexibility and reuse of existing code. Some well known and most used Creational Design Patterns are:

a. Singleton - It describes how we can create only one single instance or object of a class.

b. Factory / Factory method - It describes how we can create objects through a interface or methods.

c. Abstract factory - It says us about the procedure of creating related group of objects when we need them.

d. Builder - It helps us construct complex objects step by step. The pattern allows you to produce different types and representations of an object using the same construction?code.

e. Prototype - This patters gives us a way to copy existing objects without making your code dependent on their?classes.

2. Structural Design Patterns:

After creating lots of objects we need to organize them so that they are lying into a proper structure and we can reuse, extend and handling them as a hassle free manner. Here's comes the structural design patterns who explains how to assemble objects and classes into larger structures, while keeping these structures flexible and efficient. It also ensure that functionalities are properly separated, encapsulated. It reduces the minimal interface between interdependent things. Some well known and most used structural design patterns are:

a. Decorator - It allows us attach new behaviors to objects by placing these objects inside special wrapper objects that contain the?behaviors.

b. Adapter - It allows objects with incompatible interfaces to?collaborate.

c. Composite - It composes objects into tree structures and then work with these structures as if they were individual?objects.

d. Facade - It provides a simplified interface to a library, a framework, or any other complex set of?classes.

e. Proxy - It provides a substitute or placeholder for another object. A proxy controls access to the original object, allowing you to perform something either before or after the request gets through to the original?object.

3. Behavioral Design Patterns:

As a mention in the story section, for aa successful and well maintained big system creation things and structure them is not all about, controlling the behaviors is also equally important. Behavioral design patterns perform this vital role. It takes care of effective communication and the assignment of responsibilities between objects. It describes interactions between objects and focus on how objects communicate with each other. Some well known and most used behavioral design patterns are:

a. Strategy - It defines a family of algorithms, put each of them into a separate class, and make their objects?interchangeable.

b. Observer - It defines a subscription mechanism to notify multiple objects about any events that happen to the object they’re?observing.

c. Mediator - It reduces chaotic dependencies between objects. The pattern restricts direct communications between the objects and forces them to collaborate only via a mediator?object.

d. Command - It turns a request into a stand-alone object that contains all information about the request. This transformation lets you pass requests as a method arguments, delay or queue a request’s execution, and support undoable?operations.

e. Template method - It defines the skeleton of an algorithm in the superclass but lets subclasses override specific steps of the algorithm without changing its?structure.

要查看或添加评论,请登录

Saiful Islam Rasel的更多文章

社区洞察

其他会员也浏览了