Skip to main content

Introduction

Structural design patterns help organize and structure classes and objects to create a well-organized system. They are like blueprints that define how different parts of a system interact, ensuring clarity and efficiency in the overall design.

Official Definition

Structural design patterns are concerned with composing classes and objects to create larger structures, making it easier to understand and manage complex systems. They provide different ways to build relationships between objects, emphasizing the composition of classes and objects to form larger structures. These patterns promote flexibility, reusability, and a clear organization of components within a software system.

Considerations

Considerations in structural design patterns involve ensuring that the relationships between objects are appropriately defined and maintained. It's essential to strike a balance between flexibility and simplicity while avoiding overly complex hierarchies or dependencies.

Objectives

Adapter Pattern

  • Objective:
    Enable the interaction between incompatible interfaces by introducing a wrapper that translates one interface into another.
  • Summary:
    The Adapter Pattern allows objects with incompatible interfaces to work together by providing a wrapper (adapter) that translates the interface of one class into the interface expected by the client.

Bridge Pattern

  • Objective:
    Separate abstraction from implementation to allow both to evolve independently.
  • Summary:
    The Bridge Pattern involves creating two independent hierarchies—one for abstraction and another for implementation—allowing changes in one to occur without affecting the other.

Composite Pattern

  • Objective:
    Compose objects into tree structures to represent part-whole hierarchies, treating individual objects and compositions of objects uniformly.
  • Summary:
    The Composite Pattern allows clients to treat individual objects and compositions of objects uniformly by organizing them into tree structures, making it easier to work with both individual and composite elements.

Decorator Pattern

  • Objective:
    Attach additional responsibilities to objects dynamically, extending functionality without altering their structure.
  • Summary:
    The Decorator Pattern involves attaching new behaviors to objects by wrapping them with decorator classes. This allows for dynamic extension of an object's functionality without altering its structure.

Facade Pattern

  • Objective:
    Provide a simplified interface to a set of interfaces in a subsystem, making it easier to use.
  • Summary:
    The Facade Pattern involves creating a simplified interface that wraps a set of interfaces in a subsystem, providing a higher-level and more user-friendly interface for the client.

Flyweight Pattern

  • Objective:
    Minimize memory usage or computational expenses by sharing objects that are used repeatedly.
  • Summary:
    The Flyweight Pattern aims to reduce memory usage by sharing common parts of objects between multiple instances, effectively minimizing the storage needed for similar objects.

Proxy Pattern

  • Objective:
    Control access to an object by acting as a surrogate, adding a level of indirection.
  • Summary:
    The Proxy Pattern involves creating a surrogate or placeholder for another object to control access, acting as an intermediary to manage interactions with the actual object.