Introduction to Design Patterns
The idea of design patterns was introduced by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (Gang of Four). They distributed a book called “Design Pattern-Elements of Reusable Object-Oriented Software” in 1994 which prompted the development of design pattern ideas.
What is Design Pattern?
Designing object-oriented software is hard and designing reusable object-oriented software is even harder. To accomplish best practices in object-oriented programming, software engineers use Design Patterns. It is not a completed design that can be changed straightforwardly into code. It is a layout for how to tackle an issue that can be utilized in a wide range of circumstances. In the simplest way, we can describe design patterns as a common solution given for most of the problems which programmers faced during the development process. These solutions were acquired by experimentation by various programming engineers over a significant considerable period. According to the Gand of Four (Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides), design patterns are principally dependent on the accompanying standards of object-oriented design.
- program to an interface, not an implementation.
- favor object composition over inheritance.
According to the book called ‘Design Pattern-Elements of Reusable Object-Oriented Software’, Gang of Four has mentioned that in general, a pattern has 4 essential elements which are ‘The pattern name’, ‘The problem’, ‘The solution and ‘The consequences ’
Usage of Design Patterns
If we go through the main usage of the design patterns is to have a common way of implementing the flow of the program and also using these design patterns, a programmer has a chance to speed up the development process by giving tested, proven development paradigms. Most people just see how to apply specific programming design strategies to specific issues. These procedures are hard to apply to a more extensive scope of issues. design patterns give general solutions, reported in a layout/format that doesn’t need points of interest attached to a specific issue. Design patterns are reusable and it provides transparency to the application design and further, improve code readability. Consequently, learning these design patterns assists unpracticed programmers with building their code in a very much organized manner.
Types of Design Patterns
According to the book, ‘Design Pattern-Elements of Reusable Object-Oriented Software’ which was published by Gang of Four, design patterns are categorized into 3 different categories named as below.
- Creational Pattern
- Structural Pattern
- Behavioral Pattern
Creational Pattern — These design patterns are involved with the way of creating the objects. It allows creating objects without uncovering the creation logic therefore, we can give the type of object which we need and it will give us that object. Thus, it avoids instantiating objects straightforwardly, using the ‘new’ keyword. These creational design patterns provide more flexibility and increase the reusability of code.
- Singleton Design Pattern
- Factory Design Pattern
- Abstract Factory Design Pattern
- Builder Design Pattern
- Prototype Design Pattern
Structural Pattern— These design patterns are involved to define the composition and structure of classes and objects and this uses the concept of inheritance for the procedure of composing interfaces and by using this type of design pattern, it helps to provide flexibility to classes and objects.
- Adapter Design Pattern
- Composite Design Pattern
- Proxy Design Pattern
- Fly Weight Design Pattern
- Facade Design Pattern
- Bridge Design Pattern
- Decorator Design Pattern
Behavioral Pattern — This pattern is involved in communication (eg: how communication happens, when objects interact with each other), interaction and assignment of responsibilities between objects.
- Template Design Pattern
- MediatorDesign Pattern
- Chain of Responsibility Design Pattern
- Observer Design Pattern
- Strategy Design Pattern
- Command Design Pattern
- State Design Pattern
- Visitor Design Pattern
- Iterator Design Pattern
- Interpreter Design Pattern
- Memento Design Pattern
From the upcoming stories, I will talk about some of the design patterns. GoodBye for now…..