What is a potential drawback of NOT following SRP?
Classes become more reusable and easier to understand.
Classes become more focused and have a clearer purpose.
Changes in one part of the code are less likely to affect other parts.
The codebase becomes more difficult to maintain and prone to bugs.
Consider a 'NotificationService' responsible for sending notifications. Which option violates DIP?
The 'NotificationService' depends on an 'INotificationChannel' interface.
Different channels like 'SMSChannel' implement the 'INotificationChannel' interface.
The 'NotificationService' accepts an 'INotificationChannel' in its constructor.
The 'NotificationService' directly instantiates and uses an 'EmailSender' class.
Which of the following best describes the Dependency Inversion Principle (DIP)?
High-level modules should depend on low-level modules.
Abstractions should depend on concrete implementations.
Low-level modules should depend on high-level modules.
Both high-level and low-level modules should depend on abstractions.
In the context of LSP, what is meant by 'substitutability'?
The practice of always using abstract classes instead of concrete classes.
The ability to change the behavior of a superclass by modifying its subclass.
The idea that all methods in a subclass should be static.
The capability to use a subclass object wherever a superclass object is expected without causing issues.
Which of these techniques can help achieve the Open/Closed Principle?
Using abstract classes and interfaces.
Avoiding the use of design patterns.
Copying and pasting code to create new functionality.
Hardcoding values directly into classes.
How can you identify potential violations of the Liskov Substitution Principle in your code?
By avoiding inheritance altogether and favoring composition.
By ensuring all methods in subclasses are static.
By looking for instances where a subclass throws an exception not declared in the superclass or introduces behavior that breaks the superclass's contract.
By only using abstract classes and interfaces.
Which of these is NOT a benefit commonly associated with applying the Dependency Inversion Principle?
Improved testability
Enhanced code reusability
Reduced code coupling
Increased code complexity
Which of the following scenarios most likely violates the Liskov Substitution Principle?
A subclass overrides a method of its superclass and provides additional functionality.
A subclass throws an exception that is not declared in the superclass's method signature.
A subclass has more attributes than its superclass.
A subclass implements an interface that the superclass does not implement.
Imagine a class named 'Employee' that handles both employee data (like name, ID) and database operations. What SOLID principle does this violate?
Open/Closed Principle
Liskov Substitution Principle
Single Responsibility Principle
Interface Segregation Principle
SOLID principles primarily aim to improve which aspect of software development?
Execution Speed
Algorithm Efficiency
Code Maintainability
Memory Optimization