3 ms·
Why not just use less dots to begin with? Or, in other words, apply the Law of Demeter[0]. To me, diving so many levels deep into dependencies is a code smell b
by jameslk 11y ago
Why not just use less dots to begin with? Or, in other words, apply the Law of Demeter[0]. To me, diving so many levels deep into dependencies is a code smell because it tightly couples code to sub-dependencies and makes refactoring more difficult.
0. https://en.wikipedia.org/wiki/Law_of_Demeter https://en.wikipedia.org/wiki/Law_of_Demeter
- daxfohl 11y agoThis is important for typical OO chaining i.e. you should avoid: serviceX.getServiceY().getServiceZ().getSomeValue(); But for just structured data it's not constructive to write accessor wrappers at each level. And for things like recursive data structures, it's not even possible.
- oofabz 11y agoMore about the Law of Demeter at Ward's Wiki: http://c2.com/cgi/wiki?LawOfDemeter http://c2.com/cgi/wiki?LawOfDemeter
- lmm 11y agoMonads are very useful for what OO people sometimes call "cross-cutting concerns" - something that's relevant at many levels but not the primary purpose of any one function. E.g. error handling, async, audit logs, database transaction boundaries.