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
Adapter

Also known as

Wrapper

Intent

The Adapter pattern converts the interface of a class into another interface that clients expect, enabling compatibility.

Explanation

Real-world example

Consider that you have some pictures on your memory card and you need to transfer them to your computer. To transfer them, you need some kind of adapter that is compatible with your computer ports so that you can attach a memory card to your computer. In this case card reader is an adapter. Another example would be the famous power adapter; a three-legged plug can't be connected to a two-pronged outlet, it needs to use a power adapter that makes it compatible with the two-pronged outlets. Yet another example would be a translator translating words spoken by one person to another


iluwatarAbout 3 minStructuralCompatibilityGang of FourIntegration
Ambassador

Intent

Provide a helper service instance on a client and offload common functionality away from a shared resource.

Also known as

  • Sidecar

Explanation

Real world example

A remote service has many clients accessing a function it provides. The service is a legacy application and is impossible to update. Large numbers of requests from users are causing connectivity issues. New rules for request frequency should be implemented along with latency checks and client-side logging.


iluwatarAbout 4 minStructuralDecouplingCloud distributed
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
Business Delegate

Intent

The Business Delegate pattern adds an abstraction layer between presentation and business tiers. By using the pattern we gain loose coupling between the tiers and encapsulate knowledge about how to locate, connect to, and interact with the business objects that make up the application.


iluwatarAbout 2 minStructuralDecoupling
Component

Also known as

  • Entity-Component-System (ECS)
  • Component-Entity-System (CES)
  • Component-Based Architecture (CBA)

Intent

The Component design pattern aims to organize code into reusable, interchangeable components, promoting flexibility and ease of maintenance in game development by allowing entities to be configured with varying behaviors.


iluwatarAbout 3 minStructuralGame programmingDecouplingModularity
Composite

Also known as

  • Object Tree
  • Composite Structure

Intent

Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.

Explanation

Real-world example


iluwatarAbout 3 minStructuralGang of FourObject compositionRecursion
Composite Entity

Also known as

  • Coarse-Grained Entity

Intent

The Composite Entity design pattern is aimed at managing a set of interrelated persistent objects as if they were a single entity. It is commonly used in the context of Enterprise JavaBeans (EJB) and similar enterprise frameworks to represent graph-based data structures within business models, enabling clients to treat them as a single unit.


iluwatarAbout 2 minStructuralClient-serverData accessEnterprise patterns
Composite View

Intent

The primary goal of the Composite View design pattern is to compose objects into tree structures to represent part-whole hierarchies. This allows clients to treat individual objects and compositions of objects uniformly, simplifying the management of complex structures.

Explanation


iluwatarAbout 5 minStructuralEnterprise patternsPresentation
Converter

Also known as

  • Mapper
  • Translator

Intent

The purpose of the Converter pattern is to provide a generic, common way of bidirectional conversion between corresponding types, allowing a clean implementation in which the types do not need to be aware of each other. Moreover, the Converter pattern introduces bidirectional collection mapping, reducing a boilerplate code to minimum.


iluwatarAbout 2 minStructuralCompatibilityData transformationObject mapping