• Register
188 points
‚óŹ3

Java Design patterns

posted May 13 3 min read

Hello Readers, Warm Greetings !

Have you ever wondered what is a design pattern in software world?. How are design patterns used in programming in order to make the code more maintainable?. If your answer is ‘yes’, then this post might feed you with some basic insights about design patterns and also various types of design patterns.

 

What are design patterns?

Software engineers, in their due course of work, would have faced problems. Those problems would have been recurring problem that come across often. Design patterns comes as an answer to such kind of recurring problems. They would serve as a template which the software engineers could adhere to and adapt them in their development work and apply it to a real time recurring problem and come up with a suitable design solution to the problem. The design pattern solutions, as the saying goes, they are tried and tested. Adapting the design pattern in the code is usually considered as a good practice as it tends to increase the readability and also makes the code more maintainable. 

 

Various types of design pattern:

There are many design patterns available in the java language, which is predominantly a language utilising the OOPs concept. We can easily categorise the design patterns under the 3 main types of the patterns. Mostly the used design patterns would fall under any of the 3 categories.

These design patterns can be classified as – 1)Creational design pattern 2) Structural design pattern 3) Behavioural design pattern 

We would see one by one in detail.

 

Creational Design pattern: 

These types of patterns are designed in such a way that they tend to define the way of how an object or a class would get instantiated. As the name implies, they serve as patterns for either class creation or for object creation. They tend to serve as patterns which can be template for producing reusable classes. They provide transparency in the way of how objects gets created in an application. Some of the patterns which comes under creational patterns include singleton pattern, Factory pattern, abstract factory pattern, prototype and builder pattern.

 

Structural Design Pattern: 

These types of patterns are designed in such a way that they tend to define the structure and composition of a class. These patterns when adapted will focus more on increasing the functionality of the class, without much modification on the composition of the class. The following patterns comes under structural design pattern - Adapter pattern, bridge pattern, composite pattern, decorator pattern, facade pattern, proxy and flyweight pattern.

 

Behavioural Design pattern:

These types of patterns help to bridge the communication gap between different objects in the system. They provide defined solutions on how the flow of exchange of data or signals happens between the objects, thereby achieving the desired results. Some of the behavioural design patterns include chain of responsibility pattern, command pattern, interpreter pattern, iterator pattern, mediator pattern, memento pattern, observer pattern, state pattern, strategy pattern, template pattern and visitor pattern.

 

Points to be noted:

Design patterns will only serve as templates to be adhered to a recurring problem

  • They bring more clarity and transparency to the system and application architecture
  • They are tried and tested
  • They can be reused in multiple applications.

 

We have come to the end of this post. In the subsequent posts, we would deep dive into some of the very widely used design patterns in the software industry.

Hope you found this post useful. If you have any comments, please do mention them.

Thanks for reading :)