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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a bridge pattern?

A

It decouples an abstraction from its implementation so that the two can vary independently.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly