On this page
Behavior Patterns related to algorithms and the assignment of responsibilities between objectsThey can be based on bothinheritance and composition they are all different, no central theme using completely different object oriented mechanisms, so will have some overlap generally most of the behavioral design patterns are unique in their approach it solves a problem in a particular wayClass: Use inheritance to describe algorithms and flow of controlInterpreter Template Method Object: Describe how a group of objects cooperate to perform a task that no single object can carry out aloneChain of Responsibility Command Iterator Mediator Memento Observer State Strategy Visitor Avoid coupling the sender of a request to its receiver by giving more than 1 object a chance to handle the request Chain the receiving objects and pass the request along the chain until an object handles it Deal with object relationships, which can be changed at run time and are more dynamic Almost all patterns use inheritance to some extent Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations Deal with object relationships, which can be changed at run time and are more dynamic Almost all patterns use inheritance to some extent Design patterns can address the issue of objects being able to vary tremendously in size and numberCommand pattern: yield objects responsible for only implementing a request on anther object or group of object Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language Deal with relationships between classes & their subclasses (focus on class relationships) relationships are established through inheritance, so they are static-fixed at compile time Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation Deal with object relationships, which can be changed at run time and are more dynamic Almost all patterns use inheritance to some extent often used with Composite or Visitor Define an object that encapsulates how a set of objects interact Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently Deal with object relationships, which can be changed at run time and are more dynamic Almost all patterns use inheritance to some extent Without violating encapsulation, capture and externalize an object's internal state so that the object can be restored to this state later Deal with object relationships, which can be changed at run time and are more dynamic Almost all patterns use inheritance to some extent Design patterns will also tell you what not to put in the interfacesMemento pattern: describes how to encapsulate & save the internal state of an object to allow object restoration latermust define 2 interfaces:a restricted one that lets clients hold & copy mementos a privileged one that only the original object can use to store & retrieve state in the momento Define a 1 to many dependency between objects so that when 1 object changes state, all its dependents are notified and updated automatically Deal with object relationships, which can be changed at run time and are more dynamic Almost all patterns use inheritance to some extent Allow an object to alter its behavior when its internal state changes The object will appear to change its class Deal with object relationships, which can be changed at run time and are more dynamic Almost all patterns use inheritance to some extent Design patterns helps you to identify less-obvious abstractions & the objects that can capture themState pattern represents each state of an entity as an object Define a family of algorithms, encapsulate each 1, and make them interchangeable Strategy lets the algorithm vary independently from clients that use it Deal with object relationships, which can be changed at run time and are more dynamic Almost all patterns use inheritance to some extent Design patterns helps you to identify less-obvious abstractions & the objects that can capture themStrategy pattern describes how to implement interchangeable families of algorithms Define the skeleton of an algorithm in an operation, deferring some steps to subclasses Template method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure Deal with relationships between classes & their subclasses (focus on class relationships) relationships are established through inheritance, so they are static-fixed at compile time Represent an operation to be performed on the elements of an object structure Visitor lets you define a new operation without changing the classes of the elements on which it operates Deal with object relationships, which can be changed at run time and are more dynamic Almost all patterns use inheritance to some extent often used with Iterator or Composite Design patterns can address the issue of objects being able to vary tremendously in size and numberVisitor pattern: yield objects responsible for only implementing a request on anther object or group of object Design patterns specify relationships between interfaces, by requiring some classes to have similar interfaces or placing constraints on the interfaces of some classesVisitor pattern: visitor interface must reflect all classes of objects that visitors can visit