Module Quiz
Complete this quiz after finishing all concept and practice pages. Save your answers before opening separate quiz calibration.
Current Module Questions
Question 1: Factory Method vs Abstract Factory
What is the single most important structural difference between Factory Method and Abstract Factory?
Question 2: Builder Invariants
Why should a Builder validate invariants inside build() rather than inside each setter?
Question 3: Adapter vs Facade
You are wrapping a third-party Stripe SDK and exposing a PaymentGateway with one method, charge(amount, token). Is this an Adapter or a Facade? Justify in one sentence.
Question 4: Decorator vs Proxy -- Scenario
You add a class CachingUserRepo that implements the same interface as UserRepo and, on each call, either returns a cached value or delegates and caches. Is this Decorator or Proxy? Justify by intent.
Question 5: Composite Uniform Treatment
Why does the Composite pattern require that Leaf and Composite share the same interface?
Question 6: Composite Safety vs Transparency
What is the safety-versus-transparency trade-off in Composite, and which side does Head First favor?
Question 7: Pick the Right Pattern -- Subsystem Simplification
A team works with a graphics library that exposes 40 public classes. 90% of internal callers use the same five methods across five of those classes. Which pattern applies and why?
Question 8: Pick the Right Pattern -- Cross-cutting Behavior
A service makes HTTP calls. The team wants to add retry, structured logging, and metrics without touching the existing service class. Which pattern applies and why?
Question 9: Pick the Right Pattern -- Construction Complexity
A value type has 12 fields, several optional, some mutually exclusive (e.g., body only makes sense for non-GET requests). Which pattern applies and why?
Question 10: Singleton Justification
Why is "we only ever need one of these" not, on its own, a sufficient reason to make something a Singleton?
Question 11: DI vs Service Locator
What is the difference between dependency injection and a service locator, and why is DI usually preferred?
Question 12: Composition Root
Where should new statements for infrastructure collaborators (HTTP clients, DB clients, file systems) live, and why?
Question 13: Cargo-Cult Diagnosis
You see UserServiceFactoryImpl implements UserServiceFactory which produces UserServiceImpl as the only implementation of UserService, in one place in the codebase. What are you looking at and what refactor applies?
Question 14: Simpler Alternatives
Give one example of a classical OO pattern that typically collapses to a function in languages with first-class functions, and describe the collapse.
Question 15: Pick the Right Pattern -- Orthogonal Variation
A rendering library needs to support two shape kinds (Circle, Square) and two backends (Raster, Vector). How do you avoid a combinatorial class explosion, and what pattern names the solution?
Interleaved Review Questions
Prior Module Question 1 (from S3 M3: Behavioral Patterns)
How does Strategy differ from Factory Method in terms of what varies?
Prior Module Question 2 (from S3 M3: Behavioral Patterns)
Why is Command often a useful collaborator for Decorator and Proxy?
Prior Module Question 3 (from S3 M2: Refactoring)
What refactoring move removes a cargo-culted interface with a single implementation?
Prior Module Question 4 (from S3 M1: OOD Foundations)
How does dependency injection relate to coupling and cohesion?
Prior Module Question 5 (from S2: Data Structures)
Why is a tree-based data structure a natural fit for Composite?
Self-Assessment and Remediation
Mastery Level (90-100% correct):
- Retrieval is strong; complete all module and semester evidence gates before advancing.
Proficient Level (75-89% correct):
- Review only the missed concept pages. Redo one kata per missed pattern.
Developing Level (60-74% correct):
- Rework the practice pages, especially the Composition and DI Clinic and the Interface Bridging Workshop. Pay extra attention to intent questions (Adapter vs Facade, Decorator vs Proxy).
Insufficient Level (<60% correct):
- Return to the concept sequence. Rebuild the habit of naming the force before naming the pattern. Consider revisiting Module 1 (cohesion and coupling) and Module 3 (Strategy, Command) -- many of this module's misunderstandings trace back there.
Progression boundary
Quiz performance calibrates retrieval and reasoning. It does not replace runnable work, changed-case transfer, the module assessment or required semester evidence. Consult practice calibration for the additional independent cases.