Ricardo Cardin thoughts on Single Responsibility Principle (SRP). Single Responsibility Principle is one of the 5 principles defined in SOLID principles. It should help with readability, lose coupling and cohesion of your code. Ricardo considers it to be one of the most powerful among these principles, yet one of the most misleading.
In 2006, Robert C. Marting, a.k.a. Uncle Bob, collected inside the book Agile Principles, Patterns, And Practices in C# a series of articles that represent the basis of clean programming, through the principles also known as SOLID.
SRE - Every module or class should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class.
Simpler definition: A class should have only one reason to change.
Given the above definition of the Single-Responsibility Principle, it is clear that there is no mathematical rigor to it. Every developer, using its own experience can give a different meaning to the word responsibility. The most common misunderstanding regarding responsibilities is which is the right grain to achieve.
Cohesion gives us a formal rule to apply when we are in doubt if a type owns more than one responsibility.
Author comes to conclusion that it is all about cohesion. Learn, what does he mean by that in this excellent article!
[Read More]