Structural Design Patterns Flashcards

1
Q

Name all the gof structural design patterns

A
Adapter
Bridge
Composite
Decorator
Facade
Flyweight
Proxy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Give an example of a bridge pattern

A

Composition over inheritance- this refers to a “has a” relationship between two items that could change instead of something hardwired or inherited. Example is a remote has a car.

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

Give an example of a proxy pattern

A

Apigee is a proxy pattern. Exposes the entire interface (and does some of its own stuff) diff from a facade bc a facade simplifies.

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

Give an example of a facade pattern

A

Ocr submission class. Lots of private methods under the hood but externally you just call ‘submit’.

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

Give an example of a composite pattern

A

A structure where limbs and nodes all extend an abstract class so it can be crawled. VPs and departments.

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

Give an example of a decorated pattern

A

Open for extension, closed for modification. Example is wrapper classes like Christmas tree interface that’s implemented by tree, garland, and bulbs. Allows class to be dynamically changed at runtime

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

Give an example of an adaptor pattern

A

Gives a bridge from one class to another. Mapping in rxjs subscriptions.

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

Give an example of a flyweight pattern

A

Lightweight representation of heavy objects.

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