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