The Single Responsibility Principle

"A class should have one, only one reason to change."

Robert C. Martin

This means that when we write a class, we should design it in such a way that it has only one responsibility. You should only need to change the class for one reason. If you have multiple reasons to change the class, it is violating the Single Responsibility Principle.

If a class has more than one responsibility and you make changes to a piece of code, this might break another piece of code as they are in the same class and share some dependencies. Your code might not be very decoupled.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.43.136