Recall & Review
beginner
What is the Open/Closed Principle in software design?
It means software entities like classes or modules should be open for extension but closed for modification. You can add new features without changing existing code.
Click to reveal answer
beginner
Why is the Open/Closed Principle important?
It helps keep code stable and reduces bugs by avoiding changes to tested code. It also makes adding new features easier and safer.
Click to reveal answer
intermediate
How can you apply the Open/Closed Principle in a system?
Use interfaces or abstract classes to define behavior, then add new classes to extend functionality without changing existing ones.
Click to reveal answer
beginner
Give a real-life example of the Open/Closed Principle.
Think of a smartphone app that supports new payment methods by adding new modules, without changing the core app code.
Click to reveal answer
intermediate
What can happen if you ignore the Open/Closed Principle?
You risk breaking existing features when adding new ones, making the system fragile and harder to maintain.
Click to reveal answer
What does 'closed for modification' mean in the Open/Closed Principle?
✗ Incorrect
Closed for modification means existing code should not be changed to avoid introducing bugs.
How do you make a system 'open for extension'?
✗ Incorrect
Open for extension means you can add new features by adding new code, not changing old code.
Which design tool helps implement the Open/Closed Principle?
✗ Incorrect
Interfaces and abstract classes allow adding new behaviors without modifying existing code.
Ignoring the Open/Closed Principle can lead to:
✗ Incorrect
Changing existing code often introduces bugs, making the system fragile.
Which of these is a good practice for Open/Closed Principle?
✗ Incorrect
Adding new classes to extend behavior keeps existing code unchanged.
Explain the Open/Closed Principle and why it matters in software design.
Think about how you can add features without breaking existing code.
You got /3 concepts.
Describe a simple example where applying the Open/Closed Principle improves a system.
Imagine adding a new payment method to an app without changing old code.
You got /3 concepts.