Structural Design Pattern
Structural Design Pattern
Structural Design Pattern
• A simple example:
Consider how multiple inheritance mixes two or more classes into one.
– The result is a class that combines the properties of its parent classes.
• In real world we have adapters for power supplies, adapters for camera
memory cards, and so on
Adaptor
• It is often used
– To make existing classes work with others without modifying their source code.
• Intent
– Convert the interface of a class into another interface clients expect.
– Adapter lets classes work together, that could not otherwise because of
incompatible interfaces.
Adaptor
• Implementation
Adaptee
Target
Adapter
Bridge
• Intent
– Decouple an abstraction from its implementation
• Bridge pattern
– Separates the abstract elements of a class from its technical implementation.
• Bridge pattern is useful when both the class and what it does vary often.
Bridge
• Implementation
Implementor
Abstraction
Client