Software Design

Decorator Pattern: Composable API Clients

UML Class Diagrams · made in Skemio

UML class diagram of an HttpClient interface implemented by BaseHttpClient and an abstract ClientDecorator with LoggingDecorator and RetryDecorator subclasses.
UML class diagram of an HttpClient interface implemented by BaseHttpClient and an abstract ClientDecorator with LoggingDecorator and RetryDecorator subclasses.

What it shows

  • Adds behaviors dynamically without subclass explosion or inheritance chains.
  • Wraps transparently by adhering strictly to the same client interface.
  • Allows arbitrary stacking order like logging before retry execution.

The takeaway

Wrap base behavior inside interchangeable decorators instead of mutating core classes.

More uml class diagrams