Design Pattern Design Patterns are general reusable solution to commonly occurring problems. These are the best practices, used by the experienced developers. Patterns are not complete code, but it can use as a template which can be applied to a problem. Types of Design Patterns Creational Design Pattern Structural Design Pattern Behavioral Design Pattern 3
Behavioral Design Pattern Behavioral patterns are concerned with algorithms and the assignment of responsibilities between objects . Features of Behavioral Design Pattern Defines how different objects and classes send messages to each other. Concerns with how classes and objects interact and distribute responsibility. Describes a process or a flow. Allow to abstract from complex instantiation processes . 4
1. Strategy Design Pattern simplest of all design patterns. provides great flexibility to your code. defines a family of algorithms, encapsulating each one, and making them interchangeable. lets the algorithm vary independently from the clients that use it. 5
2. Chain of Responsibility used to avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. We chain the receiving objects and pass the request along the chain until an object handles it. 6
3. Command Design Pattern helps to decouple the invoker from the receiver of a request . Its intent is to encapsulate a request as an object, thereby letting the developer to parameterize clients with different requests, queue or log requests, and support undoable operations. 7
4. Interpreter Design Pattern The Interpreter Design Pattern is a heavy-duty pattern. It define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language. 8
5. Iterator Design Pattern The Iterator pattern allows a client object to access the contents of a container in a sequential manner, without having any knowledge about the internal representation of its contents. 9
6. Mediator Design Pattern an object that encapsulates how a set of objects interact . It encapsulates the interaction between the objects and makes them independent from each other. 10
7. Memento Design Pattern It can be used to accomplish this without exposing the object’s internal structure. The object whose state needs to be captured is referred to as the originator. 11
8. Observer Design Pattern It is a kind of behavior pattern which is concerned with the assignment of responsibilities between objects. It defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. 12
9. State Design Pattern It allows an object to alter its behavior when it’s internal state changes . The object will appear to change its class. The state of an object can be defined as its exact condition at any given point of time, depending on the values of its properties or attributes. 13
10. Template Design Pattern defines the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses to redefine certain steps of an algorithm without changing the algorithm’s structure. 14
11. Visitor Design Pattern It is useful when designing an operation across a heterogeneous collection of objects of a class hierarchy. allows the operation to be defined without changing the class of any of the objects in the collection. 15
Conclusion Behavioral patterns describe not just patterns of objects or classes but also the patterns of communication between them. 16
References https:// www.tutorialspoint.com/design_pattern https:// www.javatpoint.com/design-patterns-in-java https://www.refactoring.guru/design-patterns Java Design Patterns book By Rohit Joshi 17