4 ms·
one of the cardinal rules of OO is: "each unit (method, object, whatever) should do exactly one thing"[3]. this rule is universally ignored in all the big OO co
by dustingetz 15y ago
one of the cardinal rules of OO is: "each unit (method, object, whatever) should do exactly one thing"[3]. this rule is universally ignored in all the big OO codebases I've seen[1]. applying this rule with discipline, forces you to have a better understanding of what your code is actually doing. I think, that applying this rule even in OO languages forces you towards "functional-style in the small, object-oriented in the large", and the only difference is your code will have fewer classes/methods, and more high-level data-structures with operations like list.filter on them.
[1] i get it, refactoring takes discipline and time, and desire to practice and learn[2], and a team of like minded people, on top of sensible business constraints.
[2] http://www.dustingetz.com/nostrademons-75h-work-week-harmful-to-personal-growth http://www.dustingetz.com/nostrademons-75h-work-week-harmful... [3] http://en.wikipedia.org/wiki/Single_responsibility_principle http://en.wikipedia.org/wiki/Single_responsibility_principle
edit: added source for single-responsibility principle
- SamReidHughes 15y agoThat's not a cardinal rule of OO or even a rule of OO.
- nahname 15y agoIt is if you don't want to write side effect riddled 'objects'.
- SamReidHughes 15y agoIf it's a rule it's a rule of programming in general, not OO.