Singleton: guarantees a single instance of a class and provides global access to it. It is useful for shared resources but is often criticized for introducing global state and complicating testing.
2 / 5
What does the Observer pattern provide?
Observer: defines a subscription model where a subject maintains a list of observers and notifies them of state changes. It underlies event systems and reactive UIs.
3 / 5
The Strategy pattern lets you do what?
Strategy: encapsulates a family of algorithms behind a common interface so they can be swapped at runtime. It replaces sprawling conditionals with polymorphism (e.g., different sort or pricing strategies).
4 / 5
Into which category do Factory Method and Builder fall?
Creational patterns: the GoF book groups patterns into creational (object creation, e.g., Factory, Builder, Singleton), structural (composition, e.g., Adapter, Decorator), and behavioral (interaction, e.g., Observer, Strategy).
5 / 5
The Adapter pattern is used to do what?
Adapter: a structural pattern that wraps an existing class so its interface matches what a client expects, letting otherwise incompatible code collaborate without modifying either side.