Which statement best describes the Open/Closed Principle in software design?
Think about how to add new features without changing existing code.
The Open/Closed Principle means software components should allow new functionality by adding new code (extension) without changing existing tested code (modification), reducing risk of bugs.
Why do interfaces help in designing software that is easy to extend?
Consider how different parts of software can work together without knowing internal details.
Interfaces define a common set of methods that different classes can implement differently. This allows new classes to be added without changing existing code, supporting extensibility.
What is the main problem with tight coupling between software modules when designing for change?
Think about how changes in one module affect others when they are tightly connected.
Tight coupling means modules rely on each other's internal workings. Changing one module often requires changes in others, reducing flexibility and increasing risk of bugs.
Which design pattern is primarily used to allow adding new behaviors to objects dynamically without altering their structure?
Consider which pattern wraps objects to add features at runtime.
The Decorator Pattern lets you add responsibilities to objects dynamically by wrapping them, supporting extensibility without changing original code.
Given a system where high-level modules depend directly on low-level modules, what change best aligns the design with the Dependency Inversion Principle to improve extensibility?
Think about how to invert dependencies to depend on abstractions rather than concrete details.
The Dependency Inversion Principle states that both high-level and low-level modules should depend on abstractions. This reduces direct dependencies and makes the system easier to extend and maintain.