Design Patterns & Architecture Flashcards
7 cards from real CPP practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 Design Patterns & Architecture flashcards as text
In the Abstract Factory pattern, what does the factory produce?
Answer: Families of related or dependent objects without specifying concrete classes
Abstract Factory creates families of related products ensuring compatible objects are used together without coupling to concrete classes.
Which C++ idiom most directly implements the RAII (Resource Acquisition Is Initialization) principle?
Answer: Destructor-based resource management
RAII ties resource lifetime to object lifetime using constructors for acquisition and destructors for release, ensuring cleanup even on exceptions.
In a Layered Architecture, which layer is responsible for business logic?
Answer: Domain/Business Logic layer
The Domain or Business Logic layer encapsulates rules and workflows that define the core behavior of the application.
What is the key difference between the Proxy and Decorator patterns?
Answer: Proxy controls access to the subject; Decorator adds responsibilities dynamically
Proxy manages access (lazy init, security, remote access) while Decorator transparently adds or extends behavior without changing access semantics.
Which pattern provides a simplified interface to a complex subsystem?
Answer: Facade
The Facade pattern provides a high-level, unified interface that hides the complexity of subsystem interactions from clients.
In the Builder pattern, what is the role of the Director class?
Answer: It orchestrates the construction steps using a builder
The Director defines the order of construction steps, delegating actual building to the concrete builder without knowing the product's internal structure.
Which pattern is typically used to implement event-driven systems where objects need to be notified of state changes?
Answer: Observer
The Observer pattern defines a one-to-many dependency so that when one object changes state, all dependents are notified automatically.