Structural Patterns  «Prev 

Examples of Structural patterns

The more I learn about patterns the more frequently I see them in other people's code.
The Java class library in particular seems to be littered with common design patterns. However, the Java class library documentation makes no mention of this fact. In one sense this a good idea because it makes the documentation more accessible to non-pattern-literate programmers. However, it also makes it more obscure.
For instance, more than one programmer has found themselves confused by the Reader and Writer classes in the java.io package because they do not recognize its use of the Decorator pattern.
In general, I think that if you are using a well-known pattern in your class library, it would not hurt to mention that fact in its documentation. These design patterns concern class and object composition. The concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities.

In software engineering, structural design patterns are design patterns that ease the design by identifying a simple way to realize relationships between entities.
Examples of Structural Patterns include:
  1. Adapter pattern : adapts one interface for a class into one that a client expects
    • Retrofit Interface Pattern: An adapter used as a new interface for multiple classes at the same time.
    • Adapter pipeline: Use multiple adapters for debugging purposes.
  2. Aggregate pattern: a version of the Composite pattern with methods for aggregation of children
  3. Bridge pattern: decouple an abstraction from its implementation so that the two can vary independently
    • Tombstone: An intermediate lookup object contains the real location of an object.
  4. Composite pattern: a tree structure of objects where every object has the same interface
  5. Decorator pattern : add additional functionality to a class at runtime where subclassing would result in an exponential rise of new classes
  6. Extensibility pattern: also known as Framework - hide complex code behind a simple interface
  7. Facade pattern: create a simplified interface of an existing interface to ease usage for common tasks
  8. Flyweight pattern: a high quantity of objects share a common properties object to save space
  9. Proxy pattern: a class functioning as an interface to another thing
  10. Pipes and filters: a chain of processes where the output of each process is the input of the next
  11. Private class data pattern: restrict accessor/mutator access