Design Patterns Overview
Design Patterns are very popular among software developers. A design pattern is a well-described solution to a common software problem.
Some of the benefits of using design patterns are:
- Design Patterns are already defined and provide an industry-standard approach to solve a recurring problem, so it saves time if we sensibly use the design pattern.
- Using design patterns promotes reusability that leads to more robust and highly maintainable code. It helps in reducing the total cost of ownership (TCO) of the software product.
- Since design patterns are already defined, it makes our code easy to understand and debug. It leads to faster development and new members of the team understand it easily.
Design Patterns are divided into three categories – creational, structural, and behavioral design patterns.
Creational Design Patterns
Creational design patterns provide the solution to instantiate an object in the best possible way for specific situations. The basic form of object creation could result in design problems or add unwanted complexity to the design. Creational design patterns solve this problem by controlling the object creation in different ways.
There are five creational design patterns that we will discuss.
- Singleton Pattern
- Factory Pattern
- Abstract Factory Pattern
- Builder Pattern
- Prototype Pattern
Structural Design Patterns
Structural patterns provide different ways to create a class structure, for example using inheritance and composition to create a large object from small objects.
There are seven structural design patterns that we will discuss.
- Adapter Design Pattern
- Composite Pattern
- Proxy Pattern
- Flyweight Pattern
- Facade Pattern
- Bridge Pattern
- Decorator Pattern
Behavioral Design Patterns
Behavioral patterns provide a solution for better interaction between objects and provide loose coupling and flexibility to extend easily.
There are eleven structural design patterns that we will discuss.
- Template Method Pattern
- Mediator Pattern
- Chain of Responsibility Pattern
- Observer Pattern
- Strategy Pattern
- Command Pattern
- State Pattern
- Visitor Pattern
- Interpreter Pattern
- Iterator Pattern
- Memento Pattern