The Facade pattern provides a simple interface to a complex system, hiding its internal details and making it easier to use.
Click to reveal answer
beginner
How does the Facade pattern improve system usability?
It reduces complexity by offering a single, easy-to-use interface instead of exposing many complex components directly.
Click to reveal answer
intermediate
In the Facade pattern, what role does the facade object play?
The facade object acts as a middleman that delegates client requests to the appropriate subsystems without exposing their details.
Click to reveal answer
beginner
Give a real-life example of the Facade pattern.
A universal remote control is a facade that lets you operate many devices like TV, DVD, and sound system through one simple interface.
Click to reveal answer
intermediate
What is a key benefit of using the Facade pattern in software architecture?
It promotes loose coupling by separating clients from complex subsystem implementations, making maintenance easier.
Click to reveal answer
What does the Facade pattern primarily provide?
ADirect access to all subsystem components
BA simple interface to a complex system
CMultiple interfaces for different subsystems
DA way to create new subsystem components
✗ Incorrect
The Facade pattern offers a simple interface to hide the complexity of subsystems.
Which of the following is NOT a benefit of the Facade pattern?
ASimplifies client interaction
BPromotes loose coupling
CIncreases subsystem complexity
DImproves maintainability
✗ Incorrect
The Facade pattern reduces, not increases, subsystem complexity exposure.
In the Facade pattern, who communicates directly with the subsystems?
AThe user interface
BThe client
CThe database
DThe facade object
✗ Incorrect
The facade object handles communication with subsystems, shielding clients.
Which real-life item best illustrates the Facade pattern?
AUniversal remote control
BCar engine
CSmartphone camera app
DElectric circuit board
✗ Incorrect
A universal remote controls many devices through one simple interface, like a facade.
What problem does the Facade pattern solve?
AComplex system interfaces are hard to use
BSubsystems need to be merged
CClients need direct access to internals
DSystems require more components
✗ Incorrect
The Facade pattern solves the problem of complex interfaces by simplifying them.
Explain the Facade pattern and how it helps simplify complex systems.
Think about how a single remote controls many devices.
You got /4 concepts.
Describe a real-world example of the Facade pattern and why it is useful.
Consider something that controls many things with one tool.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of the Facade pattern in system design?
easy
A. To make the system slower by adding extra layers
B. To increase the number of classes in a system
C. To provide a simple interface to a complex system
D. To replace all subsystem classes with one class
Solution
Step 1: Understand the Facade pattern role
The Facade pattern is designed to simplify interactions by providing a single interface to a complex system.
Step 2: Compare options with the pattern's purpose
To provide a simple interface to a complex system correctly states the purpose. Options A, B, and C describe incorrect or harmful effects.
Final Answer:
To provide a simple interface to a complex system -> Option C
Quick Check:
Facade pattern = Simple interface [OK]
Hint: Facade means simple front for complex system [OK]
Common Mistakes:
Thinking Facade replaces all classes
Believing Facade adds complexity
Confusing Facade with Singleton pattern
2. Which of the following is the correct way to define a Facade class method in a typical object-oriented language?
easy
A. private void complexOperation() { subsystem1.action(); }
B. public int complexOperation() { subsystem1.action(); subsystem2.action(); return 0; }
C. void complexOperation() { return subsystem1.action(); }
D. public void complexOperation() { subsystem1.action(); subsystem2.action(); }
Solution
Step 1: Identify Facade method visibility and calls
Facade methods are usually public to expose simplified operations and call multiple subsystems internally.
Step 2: Check each option's correctness
public void complexOperation() { subsystem1.action(); subsystem2.action(); } is public and calls multiple subsystems, matching Facade pattern. private void complexOperation() { subsystem1.action(); } is private, so not accessible. void complexOperation() { return subsystem1.action(); } returns a value but calls only one subsystem. public int complexOperation() { subsystem1.action(); subsystem2.action(); return 0; } returns int unnecessarily.
Final Answer:
public void complexOperation() { subsystem1.action(); subsystem2.action(); } -> Option D
Quick Check:
Facade method = public + multiple calls [OK]
Hint: Facade methods are public and call multiple subsystems [OK]
Common Mistakes:
Making Facade methods private
Returning values unnecessarily
Calling only one subsystem inside Facade
3. Given this Facade code snippet, what will be the output?
class SubsystemA {
void operationA() { print('A'); }
}
class SubsystemB {
void operationB() { print('B'); }
}
class Facade {
SubsystemA a = SubsystemA();
SubsystemB b = SubsystemB();
void doWork() {
a.operationA();
b.operationB();
}
}
void main() {
Facade f = Facade();
f.doWork();
}
medium
A. BA
B. AB
C. A B
D. No output
Solution
Step 1: Trace Facade's doWork method calls
doWork calls operationA() then operationB(), which print 'A' and 'B' respectively.
Step 2: Determine output sequence
Since operationA prints 'A' first, then operationB prints 'B', output is 'AB' without spaces.
Final Answer:
AB -> Option B
Quick Check:
Facade calls order = AB [OK]
Hint: Follow method calls in order to find output [OK]
Common Mistakes:
Assuming output is 'BA' reversing calls
Expecting spaces between prints
Thinking no output due to missing return
4. Identify the error in this Facade implementation:
class Subsystem {
void action() { print('Action'); }
}
class Facade {
Subsystem subsystem;
void doTask() {
subsystem.action();
}
}
void main() {
Facade f = Facade();
f.doTask();
}
medium
A. Subsystem object is not initialized before use
B. Facade class should not call subsystem methods
C. doTask method should return a value
D. Subsystem class should be abstract
Solution
Step 1: Check subsystem object usage in Facade
The Facade has a subsystem field but never initializes it before calling action(), causing a null reference error.
Step 2: Validate other options
Facade class should not call subsystem methods is wrong because Facade should call subsystem methods. doTask method should return a value is not required. Subsystem class should be abstract is unnecessary.
Final Answer:
Subsystem object is not initialized before use -> Option A
Quick Check:
Uninitialized object = runtime error [OK]
Hint: Always initialize objects before calling methods [OK]
Common Mistakes:
Ignoring null object initialization
Thinking Facade should not call subsystems
Expecting return values unnecessarily
5. You are designing a home automation system with many devices: lights, thermostat, security cameras, and music system. How would applying the Facade pattern help in this scenario?
hard
A. Create a single HomeAutomationFacade class that provides simple methods like turnOnAll() and setTemperature() to control all devices
B. Replace all device classes with one large class containing all device logic
C. Make each device class inherit from a common Facade superclass
D. Use Facade pattern to split each device into smaller classes
Solution
Step 1: Understand Facade's role in simplifying complex systems
Facade groups multiple subsystem calls into simple methods, hiding complexity from users.
Step 2: Apply this to home automation
Create a single HomeAutomationFacade class that provides simple methods like turnOnAll() and setTemperature() to control all devices correctly describes creating a Facade class with simple methods controlling multiple devices. Options A, B, and D misunderstand Facade's purpose.
Final Answer:
Create a single HomeAutomationFacade class that provides simple methods like turnOnAll() and setTemperature() to control all devices -> Option A
Quick Check:
Facade = simple interface for complex devices [OK]
Hint: Facade groups complex calls into simple methods [OK]
Common Mistakes:
Merging all logic into one big class
Confusing Facade with inheritance
Splitting devices further instead of simplifying
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.