Structural Design Patterns Flashcards
Name all the gof structural design patterns
Adapter Bridge Composite Decorator Facade Flyweight Proxy
Give an example of a bridge pattern
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.
Give an example of a proxy pattern
Apigee is a proxy pattern. Exposes the entire interface (and does some of its own stuff) diff from a facade bc a facade simplifies.
Give an example of a facade pattern
Ocr submission class. Lots of private methods under the hood but externally you just call ‘submit’.
Give an example of a composite pattern
A structure where limbs and nodes all extend an abstract class so it can be crawled. VPs and departments.
Give an example of a decorated pattern
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
Give an example of an adaptor pattern
Gives a bridge from one class to another. Mapping in rxjs subscriptions.
Give an example of a flyweight pattern
Lightweight representation of heavy objects.