Behavioral Patterns
- Deal with the details of assigning responsibilities between different objects
- Describe the communication mechanism between objects
- Define the mechanism for choosing different algorithms by different objects at runtime
Pattern Name | Description |
---|---|
Command | Allows a request to be encapsulated into an object giving control over request queuing, sequencing and undoing. |
Mediator | Encapsulates the direct object-to-object communication details among a set of objects in a separate (mediator) object. This eliminates the need for these objects to interact with each other directly. |
Memento | Allows the state of an object to be captured and stored. The object can be put back to this (previous) state, when needed. |
Observer | Promotes a publisher–subscriber communication model when there is a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified so they can update their state. |
Interpreter | Useful when the objective is to provide a client program or a user the ability to specify operations in a simple language. Helps in interpreting operations specified using a language, using its grammar. More suitable for languages with simple grammar. |
State | Allows the state-specific behavior of an object to be encapsulated in the form of a set of state objects. With each state-specific behavior mapped onto a specific state object, the object can change its behavior by configuring itself with an appropriate state object. |
Strategy | Allows each of a family of related algorithms to be encapsulated into a set of different subclasses (strategy objects) of a common superclass. For an object to use an algorithm, the object needs to be configured with the corresponding strategy object. With this arrangement, algorithm implementation can vary without affecting its clients. |
Null Object | Provides a way of encapsulating the (usually do nothing) behavior of a given object type into a separate null object. This object can be used to provide the default behavior when no object of the specific type is available. |
Template Method | When there is an algorithm that could be implemented in multiple ways, the template pattern enables keeping the outline of the algorithm in a separate method (Template Method) inside a class (Template Class), leaving out the specific implementations of this algorithm to different subclasses. In other words, the Template Method pattern is used to keep the invariant part of the functionality in one place and allow the subclasses to provide the implementation of the variant part. |
Object Authenticator | Useful when access to an application object is restricted and requires a client object to furnish proper authentication credentials. Uses a separate object with the responsibility of verifying the access privileges of different client objects instead of keeping this responsibility on the application object. |
Common Attribute Registry | Provides a way of designing a repository to store the common transient state of an application. |
No comments:
Post a Comment