Contemporary software development aims to fulfill a myriad of business needs while remaining relevant and easily maintained with time. The key to filling these requirements is through design patterns.
The core requirement for a software design is to provide a set of solutions to the business challenges of an organization. A design pattern is not a one size fits all solution, in fact, it can make or break an organization’s future. The key is to ensure that the software design being selected is the best solution, taking into account the organizational context.
Types of Design Patterns
(i) Structural Patterns
Structural patterns allow objects and classes to come together and form relationships in order to function together. Following are some examples of structural patterns;
Adapter: classes do not generally work together because their interfaces are unable to sync. Adapters bridge these differences and allow diverse classes to work together.
Bridge/ Composite: both these patterns arrange objects into tree like structures which symbolize a pyramid. This allows users to treat single objects and groups of objects in the same manner.
Decorator: the decorator is used for entities which demonstrate special behaviors according to specific situations. Hence the decorator is used to assign additional functionality to the entity.
Flyweight: this pattern is used when a group of objects share a core state but have diversity in the rest.
Memento: a memento saves the default state of an object to ensure easy return to that state if need be at a later stage.
Proxy: there are three kinds of proxy and all are used in some way to regulate who gets to enter or review an object.
(ii) Creational Patterns
As the name suggests, creational patterns are used to ease the creation of objects by substituting a pattern to create an object instead of the user creating the object him/ herself. Some examples are;
Singleton: this design pattern ensures that the object that you have is completely unique, and assigns a global access reference to it.
Factory Method/ Factory: this method uses the creational method to unify various classes. The Factory is a simpler form of the Factory Method.
Builder: when you need to create a complicated object which is the sum of many, a builder is the ideal interface.
Prototype: this interface lets you create a new object sharing the state of the original object foregoing the need for the class.
(iii) Behavioral Design Patterns
These patterns dictate how objects will communicate to each other. Some examples are;
Chain of Responsibility: this template creates a chain of objects which bounce a request to each other till the first available object can fulfill it.
Strategy pattern: the program decides which course to take based on the situation the organization is in.