How to leverage and impart knowledge on Java Design Patterns in the team
Design Patterns help us to solve a problem during project development. Moreover, Design Patterns will help us in fixing performance and memory related issues. If you have strong concepts in Java Design Patterns, your confidence level will also be high because design patterns itself provide you solutions for many common use cases. Also, you will never feel low while developing a project. Even you will be able to suggest a better solution to a problem instead of the existing one.
If you are strong in design patterns, you will complete your development earlier than the expected time and number of bugs will also be very negligible. In contrast, if you are weak in design patterns, you will face a lot of problems while developing, even sometimes you may need to modify your code from the beginning, that can result in pain & frustration.
What are the advantages of using Design Patterns?
- Design Patterns help in finding the solution of a complex problem.
- Using design patterns, we can make our code loosely-coupled.
- It will have the option of reusable codes, which reduce the total development cost of the application.
- Developers feel the code more user-friendly.
- It has all the standard approaches to find out solutions to the common problem of a software.
- We can use the same pattern repeatedly in multiple projects.
- It helps in refactoring our code in a better way.
How to leverage and impart knowledge on Java Design Patterns in the team
If you know Design Patterns, it will lead to better code structure, better communication, and, best of all, it will save you a lot of time that you can spend on cooler things. Moreover, Design Patterns will also be useful in your Professional Career in multiple places.
♦ In Code Comments and Naming Conventions: When you’re writing code, clearly identify the patterns you’re using in the comments. Also, choose class and method names that follow any patterns. As a result, other developers who have to read your code will thank you for allowing them to quickly understand your implementation.
♦ In Architecture Documentation: When you write architectural documentation, using patterns will reduce the amount of documentation you need to write and gives the reader a clearer picture of the design.
♦ In Groups of Interested Developers: Share your knowledge as much as possible. Generally, many developers have heard about patterns, but don’t have a good understanding of what they are. Volunteer to give a brown-bag lunch on patterns or a talk at your local user group.
♦ In Project Meetings: When you meet with your team to discuss a software design, use design patterns to help stay “in the design” longer.
Design Pattern’s Quick References
In fact, my target is to make you remember the Design Patterns in Java as a vocabulary. So, now it’s time to provide the short descriptions of each design pattern so that you can memorize it easily. Below is the quick references of Design patterns in Java as a one liner definition of each patterns, just to memorize while revising the concepts. However, keep in mind that patterns are not kept in sequence to make you exercise in a better way...
Pattern Description
Decorator Wraps an object to provide new behavior
State Encapsulate state-based behaviors and uses delegation to switch between behaviors
Iterator Provides a way to traverse a collection of objects without exposing its implementation
Façade Simplifies the interface of a set of classes
Strategy Encapsulate interchangeable behavior and uses delegation to decide which one to use
Proxy Wraps an object to control access to it
Factory Method Subclasses decide which concrete class to create
Adapter Wraps an object and provides a different interface to it
Observer Allows objects to be notified when state changes
Template Method Subclasses decide how to implement steps in an algorithm
Composite Clients treat collection of objects an individual object uniformly
Singleton Ensures one and only one object is created
Abstract Factory Allows a client to create families of objects without specifying their concrete classes
Command Encapsulates a request as an object
Bridge Allows abstractions & implementations to be extended independently
Builder Encapsulate the construction of a product & allows it to be constructed in steps
Chain of Responsibility Allows to add or remove responsibilities dynamically by changing the members or order of the members in the chain
Flyweight Reduces the number of object instances at runtime, saving memory
Interpreter Builds an interpreter for a language
Mediator Centralizes complex communications and controls between related objects
Memento Returns an object to one of its previous state
Prototype Creates an instance of a given class when creation is either expensive or complicated
Visitor Adds capabilities to a composite of Objects when encapsulation is not important
I will go through the implementation of each pattern in details in upcoming articles however you can refer the link below for references - https://github.com/sureshkrmahto/Master