Difficulty: Easy
Correct Answer: False
Explanation:
Introduction / Context:
One of the strengths of object-oriented design is extensibility: the ability to add new types without rewriting existing, stable code. The Open/Closed Principle states that software entities should be open for extension but closed for modification. This question asks whether introducing a derived class should force fundamental changes to the base class.
Given Data / Assumptions:
Concept / Approach:
If the base class is properly abstracted and encapsulates its invariants, adding a new derived class should not require altering the base's interface or internals. Instead, the derived class overrides virtual functions or adds new members. This promotes maintainability and reduces ripple effects across codebases.
Step-by-Step Solution:
Define a stable base interface with virtual functions where variation is expected.Implement new behavior by deriving a subclass and overriding the relevant virtuals.Confirm no fundamental changes are needed in the base if it already models the abstraction correctly.Therefore, the statement that base class changes are required is false in good designs.
Verification / Alternative check:
Frameworks (GUI toolkits, plugin systems) allow third parties to add derived classes without patching the base library, validating the principle.
Why Other Options Are Wrong:
Common Pitfalls:
Coupling base classes to specific derived behaviors. Prefer dependency inversion and virtual interfaces to avoid editing base code for each extension.
Final Answer:
False.
Discussion & Comments