Worksheetsstructural Design Patterns Quiz
Total questions: 10
Worksheet time: 5mins
A client needs to place an order but must call Inventory, Payment, Shipping, and Notification services in the correct order. Which pattern can simplify this interaction?
Decorator
Adapter
Facade
Proxy
Which situation best indicates the need for a Facade?
Adding new behavior to an object at runtime
Hiding complex subsystem interactions behind a single method
Converting one interface into another
Restricting access to an object
You want to add logging, caching, and validation to a service without changing its existing code. Which pattern fits best?
Facade
Decorator
Adapter
Singleton
What is the main benefit of using a Facade?
Improves performance
Reduces number of classes
Reduces coupling between client and subsystems
Enables multiple inheritance
Which scenario best suits the Decorator pattern?
Simplifying a complex workflow
Creating related objects together
Adding responsibilities dynamically
Ensuring only one object exists
Why is Decorator preferred over inheritance in some cases?
It improves compile-time safety
It avoids deep inheritance hierarchies
It guarantees faster execution
It removes the need for interfaces
A notification system supports Email. Later, SMS and Push must be added in any combination at runtime. Which pattern solves this without creating many subclasses?
Facade
Builder
Decorator
Factory
A client calls a single method PlaceOrder() instead of interacting with five different services. Which pattern is being used?
Proxy
Decorator
Facade
Adapter
Which statement best differentiates Facade from Decorator?
Facade adds behavior; Decorator hides complexity
Facade simplifies usage; Decorator enhances behavior
Both modify object behavior
Both wrap objects for security
If adding a new feature requires wrapping an existing object rather than modifying it, which principle is mainly supported?
Single Responsibility Principle
Open/Closed Principle
Dependency Inversion Principle
Interface Segregation Principle
