๐ Design Pattern ยท flashcards
Design Pattern Design Patterns Flashcards
51 question-and-answer cards covering Design Patterns as it is examined in Design Pattern. 24 of them are printed below, taken from across the deck โ no signup, no paywall on the preview.
24 sample cards from the Design Patterns deck
Sampled from the end of the deck, so these are different cards from the ones shown on the syllabus page.
What is the intent of the Flyweight pattern?
Use sharing to support large numbers of fine-grained objects efficiently by sharing common state among them.
In Flyweight, distinguish intrinsic state from extrinsic state.
Intrinsic state is shared, context-independent data stored inside the flyweight; extrinsic state is context-dependent data supplied by the client and passed in on each operation (not stored).
Which pattern would you use to reduce memory when rendering thousands of tree objects that share the same texture and mesh?
Flyweight, storing the shared texture/mesh as intrinsic state and passing per-tree position/scale as extrinsic state.
What is the intent of the Proxy pattern?
Provide a surrogate or placeholder for another object to control access to it.
Name four common variants of the Proxy pattern.
Virtual proxy (lazy creation of expensive objects), remote proxy (represents an object in another address space), protection proxy (controls access rights), and smart reference/smart proxy (adds actions like reference counting or locking).
How do Proxy and Decorator differ in intent despite similar structure?
Both wrap an object with the same interface, but Proxy controls access to the object (often managing its lifetime/location), while Decorator adds new responsibilities/behavior.
What is the intent of the Chain of Responsibility pattern?
Avoid coupling the sender of a request to its receiver by giving multiple objects a chance to handle the request, passing it along a chain until one handles it.
In Chain of Responsibility, what happens if no handler in the chain handles the request?
The request falls off the end of the chain unhandled (it may be ignored or trigger a default action); handling is not guaranteed.
What is the intent of the Command pattern?
Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.
Name the participant roles in the Command pattern.
Command (interface with execute), ConcreteCommand, Receiver (does the work), Invoker (triggers the command), and Client (creates and configures commands).
Which method is typically added to a Command interface to support undo functionality?
An 'undo()' (or 'unexecute()') method that reverses the effect of the corresponding execute().
What is the intent of the Interpreter pattern?
Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.
In Interpreter, what is the distinction between a TerminalExpression and a NonterminalExpression?
A TerminalExpression implements interpretation for a leaf/atomic grammar symbol; a NonterminalExpression represents a grammar rule composed of other expressions and interprets by recursively invoking its children.
What is the intent of the Iterator pattern?
Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.
What is the difference between an internal (passive) and an external (active) iterator?
With an external iterator the client controls the iteration and explicitly requests the next element; with an internal iterator the iterator controls iteration and applies a supplied operation to each element itself.
What is the intent of the Mediator pattern?
Define an object that encapsulates how a set of objects interact, promoting loose coupling by keeping objects from referring to each other explicitly.
How does Mediator change the communication topology among colleague objects?
It converts a many-to-many web of direct references between colleagues into a hub-and-spoke (star) topology where all colleagues communicate only through the mediator.
What is the intent of the Memento pattern?
Without violating encapsulation, capture and externalize an object's internal state so that the object can be restored to this state later.
Name the three participants of the Memento pattern.
Originator (creates and restores from mementos), Memento (stores the originator's internal state), and Caretaker (keeps mementos but never inspects their contents).
In Memento, why must the Caretaker treat the memento as opaque?
To preserve encapsulation: only the Originator may read or modify the memento's stored state; the Caretaker just holds and returns it, never examining its internals.
Which behavioral pattern is the natural basis for implementing undo/redo history, and what role stores each snapshot?
The Memento pattern; the Caretaker stores a stack of Memento snapshots produced by the Originator, restoring one to undo.
Which two patterns are commonly combined so that each queued Command object can be undone by saving state in a Memento?
Command and Memento: the Command captures the Receiver's prior state in a Memento before executing, enabling undo.
Which single creational pattern is inherently limited to producing one instance, and which produces whole families of related objects?
Singleton produces exactly one instance; Abstract Factory produces families of related objects.
Give one concrete example use case each for Facade, Flyweight, and Chain of Responsibility.
Facade: a simple API wrapping a complex compiler/subsystem. Flyweight: sharing glyph objects in a text editor. Chain of Responsibility: an event-handling or middleware pipeline where each handler may process or pass the event on.
What this deck covers
The Design Patterns deck follows the Design Pattern Design Patterns syllabus โ 5 chapters and 39 topics โ so questions land on material that is genuinely examinable rather than trivia around it. That works out to roughly 10.2 cards per chapter.
Answers are written to be recallable, not just readable โ averaging about 152 characters, which is long enough to carry the reasoning and short enough to say out loud.
A deck like this earns its keep on the second and third pass. Read the syllabus first so you know the shape of the subject, then use the cards to find the specific facts that have not stuck.
Design Patterns flashcards FAQ
How many Design Patterns flashcards are in this Design Pattern deck?
51 cards. This page previews 24 of them, sampled evenly across the deck so you can judge the difficulty before installing anything.
Are these Design Pattern flashcards free?
Yes. The preview here is free to read with no signup, and the full 51-card deck is free inside the Examius app.
What do the Design Patterns cards cover?
They follow the Design Pattern Design Patterns syllabus โ 5 chapters and 39 topics โ so the questions track what is actually examinable.
How should I use these flashcards?
Read the syllabus first so you know the shape of the subject, then drill the deck. Examius schedules each card with spaced repetition, so cards you keep missing come back sooner and ones you know drift further apart.