|
Behavioral pattern
Behavioral patterns describe the ways objects and classes interact and divide responsibilities among themselves. By changing the object or class one can change the algorithm used, the objects affected, or the behavior while retaining the same interface for the clients.
Behavioral class patterns use inheritance, subclassing and polymorphism to adjust the steps taken during a process. It focuses on changing the exact algorithm used or task performed depending on circumstances.
Behavioral object patterns describe how different objects work together to accomplish a task. It would be difficult or impossible to accomplish with single objects.
Benefits of behavioral patterns are (1) decoupling objects from the objects that send requests to them and that they send requests to (2) Allowing algorithms to be parameterized and selected dynamically (3) Queuing messages and executing them in sequence.
Common behavioral patterns are
(1) Chain of Responsibility pattern - describes a system in which different objects each receive an opportunity to handle a request. The request propagates up the chain until some object handles it.
(2) Command pattern - wraps requests from one object to another within a class.
(3) Iterator pattern - describes an abstract means of passing through each of the elements in a collection. It separates the enumeration of the collection from the way the collection is stored.
(4) Mediator pattern - allows many different objects of the same or different classes that need to communicate with each other to each communicate only with a single class.
(5) Observer pattern - allows an object to notice and react to changes in another object.
(6) Strategy pattern - allows different algorithms to be incorporated into different classes and changed dynamically at runtime depending on the specific needs.
(7) Visitor pattern - allows definition of a new operation without changing the classes of the elements on which it operates.
What is a Design Pattern?
Creational Design Pattern
Structural Design Pattern
Behavioral Design Pattern
Why use Design Patterns?
Want to learn more?
|