Freigeben über


Making it easy is not a single responsibility

The single responsibility principle is generally considered to be a good principle when designing software. My experience is that code written using this principle turns out to be easier to understand, test and maintain. But what is a responsibility? Could making it easy to develop X be a good responsibility? No that is not a good responsibility since almost all design and abstraction in your software has one goal; making it easy to write your application. So if you choose this as your definition of single responsability you'll basically end up with a single class with lots of methods because the single class' responsability is to make it easy to implement the application.

So what is a good definition of single responsibility. I like the definition that responsibility is reason to change. If the object have one reason to change it has a single responsibility.