Skip to main content
Abstract Document

Intent

The Abstract Document design pattern is a structural design pattern that aims to provide a consistent way to handle hierarchical and tree-like data structures by defining a common interface for various document types. It separates the core document structure from specific data formats, enabling dynamic updates and simplified maintenance.


iluwatarAbout 4 minStructuralAbstractionExtensibilityDecoupling
Acyclic Visitor

Intent

The Acyclic Visitor pattern decouples operations from an object hierarchy, allowing you to add new operations without modifying the object structure directly.

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).


iluwatarAbout 2 minBehavioralDecouplingExtensibility
Bridge

Also known as

Handle/Body

Intent

Decouple an abstraction from its implementation so that the two can vary independently.

Explanation

Real-world example

Consider you have a weapon with different enchantments, and you are supposed to allow mixing different weapons with different enchantments. What would you do? Create multiple copies of each of the weapons for each of the enchantments or would you just create separate enchantment and set it for the weapon as needed? Bridge pattern allows you to do the second.


iluwatarAbout 3 minStructuralDecouplingExtensibilityGang of Four
CRTP

Also known as

  • Recursive Type Bound
  • Recursive Generic
  • Static Polymorphism
  • Mixin Inheritance

Intent

Curiously Recurring Template Pattern (CRTP) is used to achieve a form of static polymorphism by having a class template derive from a template instantiation of its own class, allowing method overriding and polymorphic behavior at compile time rather than at runtime.


iluwatarAbout 3 minStructuralExtensibilityIdiomInstantiation
Decorator

Also known as

  • Smart Proxy
  • Wrapper

Intent

The Decorator pattern allows for the dynamic addition of responsibilities to objects without modifying their existing code. It achieves this by providing a way to "wrap" objects within objects of similar interface.


iluwatarAbout 3 minStructuralGang of FourEnhancementExtensibilityWrapping
Extension Objects

Also known as

  • Interface Extensions

Intent

The Extension Objects pattern allows for the flexible extension of an object's behavior without modifying its structure, by attaching additional objects that can dynamically add new functionality.

Explanation


iluwatarAbout 3 minStructuralEncapsulationExtensibilityObject compositionPolymorphism
Feature Toggle

Also known as

  • Feature Flag
  • Feature Switch

Intent

A technique used in software development to control and manage the rollout of specific features or functionality in a program without changing the code. It can act as an on/off switch for features depending on the status or properties of other values in the program. This is similar to A/B testing, where features are rolled out based on properties such as location or device. Implementing this design pattern can increase code complexity, and it is important to remember to remove redundant code if this design pattern is being used to phase out a system or feature.


iluwatarAbout 2 minBehavioralDecouplingExtensibilityFeature managementScalability
Log aggregation

Intent

Centralize, streamline, and optimize the process of log management so that insights can be quickly
derived, problems can be swiftly identified and resolved, and the system's overall health can be
monitored efficiently.

Explanation

Real-world example

AWS CloudWatch aggregates logs from various AWS services for monitoring and alerting.


iluwatarAbout 1 minArchitecturalMicroservicesExtensibility
Naked Objects

Intent

The naked object design pattern is a way to build user interfaces (UIs) for software applications that is based on the idea of direct manipulation. This means that users interact directly with the underlying domain objects of the application, without any intermediary UI elements.


iluwatarAbout 4 minArchitecturalDecouplingExtensibilityPresentation
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. The advantage of this approach over a working default
implementation is that a Null Object is very predictable and has no side effects: it does nothing.


iluwatarAbout 2 minBehavioralExtensibility