Java Design Patterns: Structural

This mini-series covers the structural design pattern.

Structural design patterns concern how objects and classes can be composed to form larger structures, such as complex class hierarchies or object networks.

Structural design patterns let developers create complex systems by combining simple, independent components in various ways, without having to build the entire system from scratch.

There are different structural design patterns, each of which provides a different way to compose objects and classes in order to create complex structures. Some of the most common patterns are:

Adapter:

Allows objects with incompatible interfaces to work together by providing a wrapper that adapts one object’s interface to match the other object’s interface.

Bridge:

Separates the abstraction and implementation of an object so that they can vary independently.

Composite:

Allows a group of objects to be treated as a single object, providing a consistent interface for working with both individual objects and groups of objects.

Decorator:

Enables new behavior to be added to existing objects dynamically, by wrapping the existing object with a decorator object that provides the new behavior.

Facade:

Provides a simplified, unified interface to a complex system, hiding the underlying complexity and making it easier to use.

Flyweight:

Reduces the cost of creating and managing large numbers of similar objects by sharing common data among objects and using a factory to create and manage the objects.

Proxy:

Provides a placeholder or surrogate for another object, which can be used to control access to the original object or to add additional functionality.