Mastery Check
12 interactive questions covering Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion in C++.
class User { string name; public: void changeName(string newName) { name = newName; } void saveToPostgresDB() { // Direct SQL connection code... } string getName() const { return name; } };
Robert C. Martin defines a responsibility as 'a reason to change'. If a class manages both business logic and UI rendering, changes to the UI and changes to business rules are two different reasons to modify the class, violating SRP.
Here is how you performed:
Keep practicing!