Acyclic Visitor
Intent Allow new functions to be added to existing class hierarchies without affecting those hierarchies, and without creating the troublesome dependency cycles that are inherent to the GoF Visitor Pattern. Explanation Real world example We have a hierarchy of modem classes. The modems in this hierarchy need to be visited by an external algorithm based on filtering criteria (is it Unix or DOS compatible modem). In plain words Acyclic Visitor allows functions to be added to existing class hierarchies without modifying the hierarchies.
Intent Allows encoding behavior as instructions for a virtual machine. Explanation Real world example A team is working on a new game where wizards battle against each other. The wizard behavior needs to be carefully adjusted and iterated hundreds of times through playtesting. It’s not optimal to ask the programmer to make changes each time the game designer wants to vary the behavior, so the wizard behavior is implemented as a data-driven virtual machine.
Intent The caching pattern avoids expensive re-acquisition of resources by not releasing them immediately after use. The resources retain their identity, are kept in some fast-access storage, and are re-used to avoid having to acquire them again. Explanation Real world example A team is working on a website that provides new homes for abandoned cats. People can post their cats on the website after registering, but all the new posts require approval from one of the site moderators.
Chain of responsibility
Intent 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. Explanation Real-world example The Orc King gives loud orders to his army. The closest one to react is the commander, then an officer, and then a soldier. The commander, officer, and soldier form a chain of responsibility.
Circuit Breaker
Intent Handle costly remote service calls in such a way that the failure of a single service/component cannot bring the whole application down, and we can reconnect to the service as soon as possible. Explanation Real world example Imagine a web application that has both local files/images and remote services that are used for fetching data. These remote services may be either healthy and responsive at times, or may become slow and unresponsive at some point of time due to variety of reasons.
Also known as Action, Transaction Intent Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations. Explanation Real-world example There is a wizard casting spells on a goblin. The spells are executed on the goblin one by one. The first spell shrinks the goblin and the second makes him invisible. Then the wizard reverses the spells one by one.
Intent The component design pattern enables developers to decouple attributes of an objects. Essentially allowing a single component to be inheritable by multiple domains/objects without linking the objects to each other. In addition to this benefit, the component design pattern allows developer to write maintainable and comprehensible code which is less likely to result in monolithic classes. Explanation Real world example Suppose your video game consists of a graphics component and a sound component.
Data Locality
Intent Accelerate memory access by arranging data to take advantage of CPU caching. Modern CPUs have caches to speed up memory access. These can access memory adjacent to recently accessed memory much quicker. Take advantage of that to improve performance by increasing data locality keeping data in contiguous memory in the order that you process it. Class diagram Applicability Like most optimizations, the first guideline for using the Data Locality pattern is when you have a performance problem.
Dirty Flag
Also known as IsDirty pattern Intent To avoid expensive re-acquisition of resources. The resources retain their identity, are kept in some fast-access storage, and are re-used to avoid having to acquire them again. Class diagram Applicability Use the Dirty Flag pattern when Repetitious acquisition, initialization, and release of the same resource causes unnecessary performance overhead. Credits Design Patterns: Dirty Flag J2EE Design Patterns