SE450: Review: Pattern Summary: Structuring Behavior [22/25] |
Strategy: Encapsulate variation into a separate object. A method accesses the variation (strategy) by delegating to a field or parameter.
Template Method: Encapsulate variation into a separate subclass. The template method accesses the variation (hook) by calling a method implemented in the subclass. Hook methods are often abstract in the superclass.
Command: Encapsulate a function as an object. The command can then be accessed from many places. It may also support undo/redo.
Observer (Publish/Subscribe): Allow many subscribers to observe changes in the publisher. Subscribers attach themselves to the publisher. The publisher calls back to the subscribers to notify them of changes.