In the context of SRP, what does 'reason to change' mean?
Refactoring the class for improved readability.
A change in the application's requirements related to a specific functionality.
Adding new features unrelated to the class's current responsibility.
Any modification made to the class code.
Which of the following best describes the impact of SRP on code testability?
SRP has no significant impact on the ease or difficulty of writing unit tests.
SRP makes it more complex to write unit tests as classes have intertwined functionalities.
SRP makes unit testing easier as classes are smaller and have well-defined responsibilities.
SRP makes it impossible to write unit tests as it encourages separation of concerns.
What is a key benefit of having high-level modules depend on abstractions?
It makes the high-level module reusable with different implementations.
It simplifies the low-level modules.
It reduces the number of lines of code.
It improves code readability.
In the context of ISP, why are 'role interfaces' considered good practice?
They are only applicable to abstract classes, not interfaces.
They violate the Single Responsibility Principle.
They are specific to how a particular client uses a class, regardless of its primary responsibility.
They define a broad set of methods used by many unrelated classes.
How does the Interface Segregation Principle contribute to loose coupling in software design?
By minimizing dependencies between classes to only what is absolutely necessary.
By reducing the need for unit testing.
By encouraging the use of global variables for communication between classes.
By promoting the use of concrete classes instead of interfaces.
Consider a 'NotificationService' responsible for sending notifications. Which option violates DIP?
The 'NotificationService' directly instantiates and uses an 'EmailSender' class.
The 'NotificationService' accepts an 'INotificationChannel' in its constructor.
The 'NotificationService' depends on an 'INotificationChannel' interface.
Different channels like 'SMSChannel' implement the 'INotificationChannel' interface.
Why is adhering to the Liskov Substitution Principle important in software development?
It ensures that all methods have the same name across different classes.
It promotes code reusability, maintainability, and reduces the risk of unexpected bugs when modifying code.
It helps reduce the number of lines of code.
It enforces the use of design patterns, making code more readable.
Which of the following is the most accurate description of SOLID principles?
Guidelines that help write more maintainable and scalable software
Advanced design patterns for specific software architectures
Tools for automatically generating code
Strict rules that must be followed in all programming scenarios
What is the core idea behind the Interface Segregation Principle (ISP)?
Classes should have only one responsibility.
Clients should not be forced to depend on methods they don't use.
Code should be open for extension but closed for modification.
Subclasses should be substitutable for their base classes.
In the context of DIP, what are abstractions typically represented by?
User interface components
Database connections
Interfaces or abstract classes
Concrete classes