Design pattern consists of two important words “Design” and “pattern”. Here design means software design and pattern means same type of problems (commonly occurring problems in software design).
So, design pattern is a general, reusable solution to commonly occurring problems in software design. They are like ready-made blueprints that you can customize to solve a recurring design issue in your code.
All design patterns can be categorized by their intent, or purpose. So, we can be categorized design problems into three main categories:
Creational Patterns:
Creational patterns solve the commonly occurring problems related to creation of an object of an entity. And it provides object creation mechanisms that increase flexibility and reuse of existing code.
Creational patterns mainly focus on object creation mechanisms. It helps to create objects in a such way that suits the situation. Here are some types of creational pattern:
- Singleton
- Factory Method
- Builder
Structural Patterns:
Structural patterns give you the answer to the following questions,
- How should different class relate to each other?
- What attributes and method should be in class?
- How to assemble objects and classes into larger structures, while keeping these structures flexible and efficient?
It deals with how objects and classes are composed to form larger structures while keeping the system flexible and efficient. They focus on simplifying the design by ensuring that relationships between different entities are easy to manage and extend.
Here are some types of Structural pattern:
- Adapter
- Composite
- Decorator
Behavioral Patterns:
Behavioral patterns manage the effective communication and assignment of responsibilities between objects. It focusses on how objects interact and communicate with one another effectively.
Here are some types of Behavioral pattern:
- Observer.
- Strategy.
- Command.
- Chain of Responsibility.
- Mediator.