Re:On logic in a Rails app
by stiff on Monday December 24, 2012 @12:44PM
(#4963503)
This seems to be a new trendy design pattern: wrap a single method with a class and claim you just discovered a pinnacle of object-oriented design since you respect the "Single Responsibility Principle"...
[ Parent
| on HN ]
I think what the OP is talking about is just a ruby reimagination of the Operation pattern. Most sufficiently complicated apps that implement undo / redo use "Single Responsibility Objects" to encapsulate individual user operations. Each one has a "do" method and an "undo" method, and little else. In a web service, you don't have to worry about undo server-side, so using this pattern is more an option than a necessity!
> claim you just discovered a pinnacle of object-oriented design since you respect the "Single Responsibility Principle"...
I never said that, why all the hate? I stated pretty clear that this is my approach on things, and I never pretended it to be the "right" one.
Re:On logic in a Rails app
by mattgreenrocks on Monday December 24, 2012 @09:27PM
(#4964859)
Don't sweat it! People tend to adopt different subsets of OOP and then proclaim all other subsets are wrong. Example: large-scale objects that are heavily procedural vs lots of smaller grained objects that adhere to SRP.
I've written a lot of code in both styles, and determined that SRP is a good force on my designs.