David Cooksey wrote some interesting observations on The Dangers of Single Responsibility in Programming (continued here ).
I view the SRP as one of the most important design principles, because it gives birth to loose coupling and reuse.
It can be applied on the OOD pattern level, as well as on the higher levels: layering, deployment packaging, and multi-tier architecture.
Obviously, it can be harmful when misinterpreted and misapplied. And David gave a good description of how this can happen.
Interestingly, in my career, I have very rarely encountered the SRP abuse. Much more frequently I saw designs that could definitely benefit from applying the SRP.
Can we say that “premature application of design principles is the root of all evil”? Well, yes and no. On one hand, the whole point of design patterns is that you apply them in anticipation of change, so they have to be “premature”. On the other hand, good patterns often emerge when you refactor. I’d say, it’s not possible to arrive to a well balanced design without constant refactoring. You need to both anticipate the change and embrace the change. This is the Zen of Design.
Here is a Zen quote about a pattern of two loosely coupled interacting classes:
“Just think of the trees: they let the birds perch and fly, with no
intention to call them when they come
and no longing for their return when they fly away.”
(Zen Quotes, 470-543 AD)
“Design pattern” is an anagram of “Departing nest”, found via Xworder.