solnic.eu
07 Feb '13, 9pm
Good advices... "Single Responsibility Principle on Rails Explained" by @_solnic_ #ruby #designpatterns #SRP
First of all “responsibility” is a flexible term and it should be treated this way. You need to keep redefining it depending on the current state of your project. I like to think that the more complex your project becomes the more narrow the definition of responsibilities should be. What do I mean by that? It’s simple. Let’s use the example from the mentioned post: creating a user. This can be a trivial thing to do, a matter of 1 line of code in Rails. If that’s the case would you say that creating a user must be treated as a single responsibility? Hmm I don’t think so. It’s very likely that when you start a project then entire CRUD for User is trivial, basic operations handled by Rails itself without any work from your side. In such cases I think that CRUD can be treated as a single responsibility. It is, in fact, a pretty wide definition of responsibility but that’s ok s...
Full article:
http://solnic.eu/2012/07/09/single-responsibility-princip...