Monday, May 28, 2018

Introduction to Design Patterns in Java

Leave a Comment

Introduction to Design Patterns in Java



Design patterns which are like templates in programming languages to resolve complex creational, structural and behavioral challenges, these templates make coding more organized and with better code quality.

Some of the challenges such as we need only single object of class during complete life cycle of an application such requirement is well suited for database connections or logger utility code. This can be solved by using singleton design pattern.

Another example is we need to write code which is extensible tomorrow or we should be able to plug a new component or service or algorithm with the existing code. So instead of changing ten different class it should allow us to just write new class with existing implantation and there we can write new algorithm. These are some of the examples of design pattern and when application grows efforts put in design patterns really pays off. It will give you better code quality standards, low maintenance cost and less effort when your are extending your code tomorrow.

So based on usage we have three different types of design patterns:

Creational Design Pattern

This design pattern deals with class instantiation and objects creation. In simple terms creational is all about creating object and initializing classes. Class initialization make uses of inheritance to achieve the desired behavior whereas object creation uses delegation work to different components to get it done.

Structural Design Pattern

Structural design pattern make sure the organizing the classes as the application grows and make sure any new changes to code or components are accommodated with minimum changes to exiting code and architecture.

Behavioral Design Pattern

Behavioral desing pattern is all about how components such as classes, interfaces and objects interact with each other efficiently. By following this pattern we can make sure that all components are known and well tested pattern to communicate to other components.





If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment