Design Patterns is general repeatable solution to a commonly occurring problem in software design. Rather we should call it a solution template as it will provide the standard to implement the solution not the code directly.
In 1994, four authors Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides (known as Gang of Four) published a book titled Design Patterns – Elements of Reusable Object-Oriented Software which initiated the concept of Design Pattern in Software development.
Below are some of the benifits listed for using Design Patterns:
- If we use the design pattern sensibly, it saves time as design patterns are already defined and provide industry standard approach to solve recurring problems.
- As it is predefined, it makes code easy to understand and fast to develop.
- Design patterns have been evolved over a long period of time and they provide best solutions to certain problems faced during software development. Learning these patterns helps unexperienced developers to learn software design in an easy and faster way.
- Desing patterns increase the re-usability of the code which makes it more robust and highly maintanable.
Design Patterns mainly devided into three categories in Java:
Creational Design Patterns: Creational design patterns deal with the creation of object in the best possible way in the specific situation. Some of the creational design patterns are as follow:
- Singleton Design Pattern
- Factory Design Pattern
- Abstract Factory Design Pattern
- Builder Design Pattern
- Prototype Design Pattern
- Object Pool Design Pattern
Structural Design Patterns: Structural design patterns provide different ways to create class structure. Some of the structural design patterns are as follow:
- Bridge Design Pattern
- Facade Design Pattern
- Proxy Design Pattern
- Composite Design Pattern
- Decorator Design Pattern
- Adapter Design Pattern
Behavioral Design Pattern: Behavioral design patterns provide solution for the bettern interaction between objects and how to provide loose couplings and flexibility to extend. Some of the behavioral design patterns are as follow:
- Mediator Design Pattern
- Iterator Design Pattern
- Strategy Design Pattern
- Command Design Pattern
- Interpreter Design Pattern
- Observer Design Pattern
Apart from above mentoined three main types, There are some design patterns that deals with multi-threaded programming paradigm. Those are known as Concurrency Design Patterns. Some of the concurrency design patterns are as follow:
- Producer Consumer Design Pattern
- Leaders/followers pattern
- Read write lock pattern
- Balking pattern
- Scheduler pattern
- Thread pool pattern
- Barrier pattern
- Double-checked locking
- Guarded suspension pattern
- Reactor pattern
Above mentioned design patterns are not the only available patterns. These are more frequently used.
The concept of design patterns has been criticized in several ways. As the right usage of, right design pattern at right place, in right context give the advantages if the above conditioned not satified and worng pattern is been used then it creates mess for the design. So it is atmost important task to choose the right design pattern for specific situations.
In the subsequent article we will go throuh some of the design patterns.
That's all for this topic. If you guys have any suggestions or queries, feel free to drop a comment. We would be happy to add that in our post. You can also contribute your articles by creating contributor account here.
Happy Learning 🙂
If you like the content on CodePumpkin and if you wish to do something for the community and the planet Earth, you can donate to our campaign for planting more trees at CodePumpkin Cauvery Calling Campaign.
We may not get time to plant a tree, but we can definitely donate ₹42 per Tree.
About the Author
Tags: Behavioral Design Patterns, Creational Design Patterns, Design Patterns, Structural Design Patterns
Comments and QueriesIf you want someone to read your code, please put the code inside <pre><code> and </code></pre> tags. For example:
<pre><code class="java"> String foo = "bar"; </code></pre>For more information on supported HTML tags in disqus comment, click here.