Structural Patterns Flashcards
1
Q
What’s an composite and when to use?
A
Compose objects into tree structures to represent part-whole. Used when the programmer wants to create hierarchy of objects. To treat all objects in the composite structure uniformly (e.g: Draw()). One composite can contain a leaf or another composite.
2
Q
What is a decorator?
A
Also known as a wrapper. Decorator implements a given interface and may add extra functionality like adding borders before drawing child components.
3
Q
What is a bridge pattern?
A
It decouples an abstraction from its implementation so that the two can vary independently.