Interpreter pattern

1. Usage Specialized database query languages such as SQL,RegExp. Specialized computer languages which are often used to describe communication protocols. Most general-purpose computer languages actually incorporate several specialized languages.(lua script inside game engine) 2. UML class diagram AbstractExpression Declares an abstract Interpret operation that is common to all nodes in the abstract syntax tree. TerminalExpression […]

Memento pattern

1. Usage Saves inner state of object in order to restore it in future. Usually implemented in Undo/Redo of Editors sometimes with Command Pattern. Memento in C++ implemented as Friend of Originator. Originator hide details of Memento providing narrow interface for controls. 2. UML class diagram Originator (managed a contained Memento obj), Memento(snapshot of originator […]

Chain of responsibility pattern

1. Usage Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it. [GoF, p223] Launch-and-leave requests with a single processing pipeline that contains many possible handlers. An […]


1. Usage Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality. [GoF, p175] Client-specified embellishment of a core object by recursively wrapping it. Wrapping a gift, putting it in a box, and wrapping the box. 2. UML class diagram 3. Pros Decorators provide a flexible alternative to […]