Skip to content

Latest commit

 

History

History
15 lines (11 loc) · 2.25 KB

File metadata and controls

15 lines (11 loc) · 2.25 KB

Structural Patterns

Structural design patterns are a category of design patterns that deal with object composition and relationships between objects. They are concerned with how classes and objects are composed to form larger structures and provide new functionality.

There are several structural design patterns, including:

  1. Adapter pattern - This pattern allows the interface of an existing class to be used as another interface that clients expect. It is useful when you have an existing class that cannot be modified or adapted to a new interface directly.
  2. Bridge pattern - This pattern decouples an abstraction from its implementation, allowing the two to vary independently. It is useful when you want to change the implementation of an abstraction without affecting clients that use it.
  3. Composite pattern - This pattern allows you to compose objects into tree structures to represent part-whole hierarchies. It is useful when you have a hierarchy of objects that can be treated uniformly.
  4. Decorator pattern - This pattern allows behavior to be added to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class.
  5. Facade pattern - This pattern provides a simple interface to a complex system, hiding its complexity from clients. It is useful when you have a complex system with many subsystems and want to provide a simpler interface to clients.
  6. Flyweight pattern - This pattern reduces memory usage by sharing object instances between multiple contexts. It is useful when you have a large number of similar objects that can be represented by a smaller number of shared objects.
  7. Proxy pattern - This pattern provides a surrogate or placeholder for another object to control access to it. It is useful when you want to provide a level of indirection to protect sensitive or expensive resources, or to provide lazy initialization of an object.

These patterns are useful in different scenarios, and each one provides a solution to a specific problem related to object composition and relationships. Understanding them can help you design better software systems that are more flexible, maintainable, and scalable.