Structural Patterns  «Prev  Next»

Delineating Structural Design Patterns: A Comparative Analysis with Behavioral and Creational Patterns

In software design, patterns are codified solutions to recurring problems. These patterns, famously consolidated by the Gang of Four (GoF) in their seminal book "Design Patterns: Elements of Reusable Object-Oriented Software," can be categorized into three principal groups: Creational, Structural, and Behavioral. Each category addresses a specific facet of object creation, composition, and interaction. To fully grasp the nuances and distinctiveness of Structural Design Patterns, it's imperative to juxtapose them against their Creational and Behavioral counterparts.
  1. Creational Patterns: Focus: These patterns concern themselves with the process of object creation.
    Characteristics
    1. Decouple the system from specific classes it creates.
    2. Hide the intricacies of creating and representing objects.
    3. Provide mechanisms to create objects based on requirements, rather than explicit instantiation.
    Common Patterns: Singleton, Factory Method, Abstract Factory, Builder, Prototype.
  2. Structural Patterns: Focus: The heart of Structural Patterns lies in establishing relationships between entities, ensuring they are pieced together to form larger structures in a streamlined manner.
    Characteristics
    1. Emphasize the composition of classes or objects.
    2. Focus on ensuring that different components of a system can work together efficiently.
    3. Often address the 'how': how different elements of a system are structured, ensuring scalability, flexibility, and maintainability.
    Common Patterns: Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy.
  3. Behavioral Patterns: Focus: Primarily concerned with communication between objects, these patterns define how entities interact and distribute responsibilities. Characteristics
    1. Define the roles that objects play in communication and interaction.
    2. Focus on ensuring object collaborations are defined and manageable.
    3. Emphasize on the distribution of responsibilities and the dynamic interplay between objects.

    Common Patterns: Observer, Strategy, Command, Iterator, Mediator, Memento, State, Template Method, Visitor, Chain of Responsibility, Interpreter.

Differentiating Factors

  1. Nature of Concern: While Creational Patterns revolve around the instantiation process, Structural Patterns are all about composition and ensuring different parts of the system fit together cohesively. Behavioral Patterns, on the other hand, address the dynamic interplay and communication mechanisms among objects.
  2. Level of Abstraction: Creational Patterns often operate at a level abstracted from the concrete classes in the system. Structural Patterns deal with a slightly higher level, focusing on how groups of objects or classes collaborate to form larger structures. Behavioral Patterns, meanwhile, operate at the highest level of abstraction, concentrating on wide-scale interactions and collaborations between objects.
  3. Systemic Impact: The modifications in a Creational Pattern primarily impact the instantiation process. Alterations in Structural Patterns might necessitate changes in the system's structure or the inter-relationships between its components. Modifications in Behavioral Patterns could reshape the very dynamics of object interactions and responsibilities.

While each category of the GoF patterns addresses a specific set of concerns, their true power is unleashed when they are used synergistically. Structural Design Patterns, by emphasizing composition and arrangement, act as the architectural glue, ensuring that the components instantiated by Creational Patterns can efficiently interact and communicate as elucidated by the Behavioral Patterns.
In software engineering, structural design patterns are design patterns that ease the design by identifying a simple way to realize relationships between entities. Structural patterns are for tying together existing function.
Examples of Structural Patterns include:

  1. Adapter: Adapts one interface for a class into one that a client expects
  2. Bridge: Decouple an abstraction from its implementation so that the two can vary independently
  3. Composite: A tree structure of objects where every object has the same interface
  4. Decorator : Add additional functionality to a class at runtime where subclassing would result in an exponential rise of new classes
  5. Facade: Create a simplified interface of an existing interface to ease usage for common tasks
  6. Flyweight: A high quantity of objects share a common properties object to save space
  7. Proxy: A class functioning as an interface to another thing

Sub-Patterns

  1. Aggregate: A version of the Composite pattern with methods for aggregation of children
  2. Extensibility: also known as Framework - hide complex code behind a simple interface
  3. Pipes and filters: A chain of processes where the output of each process is the input of the next
  4. Private class data: Restrict accessor/mutator access

Design phase

The phase of a software project that concerns itself with the discovery of the structural components of the software system to be built, not with implementation details.

Ad Gang of Four Patterns
Figure 3.1 provides a visualization of the Structural design patterns.
Figure 3.1: Structural patterns focus on creating new structures from existing ones

The focal points for Structural design patterns lie in creating new structures without destroying the old ones. On top of that, the standard of loose coupling for reuse and change are both maintained and enhanced in the Structural patterns.
.