Double Dispatch
Intent Double Dispatch pattern is a way to create maintainable dynamic behavior based on receiver and parameter types. Class diagram Applicability Use the Double Dispatch pattern when the dynamic behavior is not defined only based on receiving object’s type but also on the receiving method’s parameter type. Real world examples ObjectOutputStream
Execute Around
Intent Execute Around idiom frees the user from certain actions that should always be executed before and after the business method. A good example of this is resource allocation and deallocation leaving the user to specify only what to do with the resource. Explanation Real-world example A class needs to be provided for writing text strings to files. To make it easy for the user, the service class opens and closes the file automatically.
Factory Kit
Also Known As Abstract-Factory Intent Define a factory of immutable content with separated builder and factory interfaces. Explanation Real-world example Imagine a magical weapon factory that can create any type of weapon wished for. When the factory is unboxed, the master recites the weapon types needed to prepare it. After that, any of those weapon types can be summoned in an instant. In plain words Factory kit is a configurable object builder, a factory to create factories.
Factory Method
Also known as Virtual Constructor Intent Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses. Explanation Real-world example Blacksmith manufactures weapons. Elves require Elvish weapons and orcs require Orcish weapons. Depending on the customer at hand the right type of blacksmith is summoned. In plain words It provides a way to delegate the instantiation logic to child classes.
Name / classification Filterer Intent The intent of this design pattern is to introduce a functional interface that will add a functionality for container-like objects to easily return filtered versions of themselves. Explanation Real world example We are designing a threat (malware) detection software which can analyze target systems for threats that are present in it. In the design we have to take into consideration that new Threat types can be added later.
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.
Extension objects
Intent Anticipate that an object’s interface needs to be extended in the future. Additional interfaces are defined by extension objects. Class diagram Applicability Use the Extension Objects pattern when: you need to support the addition of new or unforeseen interfaces to existing classes and you don’t want to impact clients that don’t need this new interface. Extension Objects lets you keep related operations together by defining them in a separate class a class representing a key abstraction plays different roles for different clients.
Feature Toggle
Also known as Feature Flag Intent Used to switch code execution paths based on properties or groupings. Allowing new features to be released, tested and rolled out. Allowing switching back to the older feature quickly if needed. It should be noted that this pattern, can easily introduce code complexity. There is also cause for concern that the old feature that the toggle is eventually going to phase out is never removed, causing redundant code smells and increased maintainability.
Null Object
Intent In most object-oriented languages, such as Java or C#, references may be null. These references need to be checked to ensure they are not null before invoking any methods, because methods typically cannot be invoked on null references. Instead of using a null reference to convey absence of an object (for instance, a non-existent customer), one uses an object which implements the expected interface, but whose method body is empty.