An Insight into Design Patterns Used in Software Development
One of the major steps in the Software Development Life Cycle is the ‘Design’. The sole basis of this phase is built upon the usage of different design patterns by software developers. In Software Development, Design patterns are repeatable and reusable solutions for commonly occurring problems in software.
The concept of Design Patterns was initially introduced in 1994 by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides through the publication of ‘Design Patterns- Elements of Reusable Object-Oriented Software’. The pioneers of the introduction of Design Patterns into the technological world were called the Gang of Four.
According to the publication of The Gang of Four, there are 23 different design patterns that are collectively used in software development. Thereby, these 23 design patterns are categorized into 4 major groups as mentioned below. They are some of the C# design patterns in action.
- Creational Design Patterns
In this design pattern, the object is created by hiding the creation logic. This prevents the instantiation of the logic to the new operator. This pattern could be further divided into class-creational patterns and object-creational patterns. The class-creational pattern implies the usage of inheritance in the instantiation process, while the object-creational pattern uses delegation to effectively get the job done.
Some commonly used design patterns that fall under creational design patterns are factory patterns, singleton patterns, and Abstract factory patterns.
Structural Design Patterns
This design pattern mainly focuses on class and composition and uses inheritance to create interfaces. These design patterns define ways to make objects with new functionality
Adaptor design patterns, Facade design patterns, composite design patterns, and Decorator design patterns are some of the examples that fall into the category of structural design patterns
- Behavioral Design Patterns
In this design pattern, the communication between the objects is given more priority. Nonetheless, the Mediator pattern, command pattern, and interpreter pattern are common examples of behavioral design patterns.
As mentioned by the Gang of Four all design patterns follow two basic principles as follows,
- Programs to an interface and not to an implementation
- Influences object composition
Moving on, design patterns are significantly used to speed up the process of the development of software by using proven tested solutions to problems. Effective flow of the software development lifecycles mainly relies on design patterns. It ensures bug-free codes that reduce the most common problems that developers face. With the use of design patterns, the codes will be easily understandable, and object-oriented skills will be developed.
Drifting apart from the technological world, design patterns can be seen in normal real scenarios as well. Furthermore, it could be real-life scenarios related to technology as well. Thereby, this article will be mainly focused on such real examples of design patterns in real-world applications
Away from Technology – A Day to Day example of the design patterns in action
For beginners of software development or for anyone who is not a software developer all technical words would sound kind of weird. Therefore, keeping aside that, this focuses on a normal scenario and how it can be related to design patterns.
There can be various places you would introduce as your favorite food spot or restaurant. That might have become your favorite place to eat because of the dishes. The dishes are prepared to match your taste buds. This means that the chef who is well-trained and experienced prepares the dishes using a specific method. And in any case, if you want to make the same dish you tasted at your favorite restaurant then following the same technique the experienced chef followed is a must. The above dish might have been made several times by the chef to make it taste perfect, and once it was perfect the particular recipe has been used every time with no changes. Now how can this food situation be related to design patterns?
Well, here is the link! Experienced chefs relate to the software developers and the specific dish is the problem addressed in software development. The approach is the design pattern and once the dish was found to be best tasted the recipe was not changed again. In that same way, when the design pattern addresses the particular problem successfully it would be reused again with certain modifications. Simply design patterns obtain solutions through several attempts over a substantial period.
Thus, the above depicts a simple real-life implementation of design patterns that explains the situation well. Moving on, the technological field could also relate to real-life examples of design patterns.
Software Design Patterns and Its action in the Real World
In relation to the technological world, below are the list of design patterns in actions;
Factory Design Pattern
This is an easy design pattern used in software development. As an action of this method in real life, consider building a logger framework. Depending on the logic, the log messages will be displayed appropriately. The logger framework might be used by different clients therefore the main logic will be hidden from the clients. By typing on the specific message the logic will be encapsulated in the logger factory class.
Builder Design Pattern
Here, an example of creating a pizza object could be taken. For the size, and the ingredients used, constructors have to be used. The parameters might easily mix up and the developers might find it difficult when new ingredients are added.
Thereby, the builder design pattern could come to the rescue. In this design pattern, the constructor will only have mandatory parameters and methods will be set for optional parameters.
Prototype Design Pattern
In this design pattern, new objects will not be created instead the objects will be cloned. This will decrease the complexity of the created object. \
As a real-life scenario based on this design pattern, the creation of cover letters could be taken.
The cover letter for an organization is not needed to be made from the beginning every time it’s needed. As an approach based on design patterns, an appealing format that would suit everyone would be created with the personalization of the name of the organization.
Flyweight Design Pattern
This pattern defines the sharing of objects. This is for efficiency and space. Thereby this pattern is majorly used when the number of objects to be created is massive and heavy. When object creation is time-consuming and immutable.
Relating real-world examples using this design pattern, the usage of keyboard characters could be seen. For example, it is used for one object and a is used for another, and so on.
Furthermore, this design pattern could be related when drawing a lot of shapes with different colors. So here, one object will be for one color and the other for another color. If in any case the same color is used again, the specific object used for the color could be reused.
Thus, the above was a detailed and simple review of how design patterns could be related to real-world examples
The Design Patterns in actions are extremely essential for the development of software. The simplicity of design patterns is immense and the smooth flow of the software development life cycle is ensured by it. As depicted and explained above, the real-world scenarios for design patterns in technological aspects and non-technological aspects are as well.