1. Which category does the Builder pattern belong to?
- Behavioural
- Structural
- Creational
- Architectural
Show answer
Answer: Creational
Builder is about constructing objects step by step.
Lesson: What Design Patterns Are
25 questions from the Design Patterns course, each with the correct answer and an explanation. Try to answer before you open the answer.
Answer: Creational
Builder is about constructing objects step by step.
Lesson: What Design Patterns Are
Answer: Building behaviour by combining objects instead of deep subclass hierarchies
Composition keeps parts swappable and loosely coupled.
Answer: An interface and factory for a class that has only one implementation and no planned variants
Abstractions should follow real variation.
Answer: Callers depend on the interface while one place decides the concrete class
The creation decision is centralised.
Answer: Creating related objects that must belong to the same family
It keeps product families consistent.
Lesson: Abstract Factory
Answer: An options object with defaults
Object literals give named, optional parameters.
Lesson: Builder
Answer: Global access hides dependencies and makes tests share state
The global access point is the main problem.
Answer: Nested objects are shared, so changing them in one copy affects the other
Only the top level is duplicated.
Lesson: Prototype and Cloning
Answer: The single place, usually at startup, where concrete implementations are created and wired together
Wiring happens once, at the edge of the application.
Answer: When integrating a third-party API whose interface differs from the one your code expects
Adapters translate between interfaces you do not control.
Lesson: Adapter
Answer: A Decorator keeps the same interface and adds behaviour; an Adapter changes the interface
Decorators enhance; adapters translate.
Answer: It turns into a god object that knows about everything
Keep facades focused on a use case.
Lesson: Facade
Answer: Delaying loading a large image or object until it is first used
Virtual proxies support lazy loading.
Lesson: Proxy
Answer: A file system with files and folders
Composite models part-whole trees.
Lesson: Composite
Answer: A class explosion when two dimensions of variation are combined through inheritance
Bridge lets each dimension vary independently.
Lesson: Bridge and Flyweight in Brief
Answer: A function with a known signature, chosen from a map
First-class functions replace many strategy classes.
Answer: Listeners that are never removed, causing memory leaks or duplicate handling
Subscriptions need a lifecycle.
Answer: Each action is an object that stores what is needed to execute and reverse it
Encapsulated requests can be stored and reversed.
Lesson: Command
Answer: Allowed transitions are explicit, so illegal ones are rejected
Explicit transitions replace scattered flags.
Lesson: State and State Machines
Answer: Chain of Responsibility
Each middleware handles the request or passes it on.
Answer: When new node types are added frequently, because every visitor must change
Visitor favours stable types and changing operations.
Lesson: Iterator and Visitor in Brief
Answer: Tracks changes in a business operation and commits them together
It groups changes into one atomic commit.
Lesson: Architectural Patterns Overview
Answer: A class that accumulates too many unrelated responsibilities
Split it by responsibility.
Lesson: Anti-Patterns and Code Smells
Answer: With Strategy the client chooses the algorithm; with State the object changes behaviour as its own state changes
Same structure, different intent.
Answer: There is real, observed variation or change that the pattern makes easier to handle
Patterns earn their place by easing change.
Lesson: A Design Patterns Checklist