Great post on “Single Responsibility Principle”: SRP, as easy as 123… | Hadi Hariri’s Blog
Posted by jpluimers on 2010/12/22
SRP (Single Responsibility Principle) is not limited to classes.
Often I see source files running like thousands of lines.
That surely is a sign if code smell, and leads to lots of problems, especially when working with teams of people, or sharing sources across multiple projects.
SRP solves these and other problems, regardless of programming language or framework you use:
- hating your version control system because merges are a pain
- tripping over the same source file because you need to change it for the umpteenth time each from a different perspective
- searching for that line of code within dozen comment blocks that explain old versions of its intricacies
Hadi Hariri – evangelist at JetBrains – has a great post called SRP, as easy as 123… on his blog (and refers to the fantastic Clean Code book by Robert C. Martin).
SRP originates from objec oriented design, but for me, SRP is not limited to classes.
For me, SRP is all about the design of your apps and the structure of your code.
Classes are just one form of ‘boxing’ things, as are interfaces, source files, services, forms, etc.
All these boxes change, and you need to be prepared for that.
Which leads me to the statement that he only thing you know about code is that it will change.
Did I mention you need continuous integration to get a grip on change?
–jeroen
Leave a Reply