3 ms·
Mostly it's a code smell though https://en.m.wikipedia.org/wiki/Law_of_Demeter https://en.m.wikipedia.org/wiki/Law_of_Demeter
by manojlds 7y ago
Mostly it's a code smell though
https://en.m.wikipedia.org/wiki/Law_of_Demeter https://en.m.wikipedia.org/wiki/Law_of_Demeter
- Vanit 7y ago4 chains is like reaching into an XHR response to pull out the success result, so I wouldn't say that's necessarily a smell.
- mattmanser 7y agoNot really, especially when you're working with external APIs. That's when I find myself using a lot of this type of code.
- zhirzh 7y agoI'd say it is a design smell and not necessarily code smell. Any API or data interface should try to keep "optional keys" at a minimum. Depending on the language, `a.b && ...` could be checking either or both of the following: - does `a` have key 'b'? - is `a.b` truthy?
- jiofih 7y agoTell that to the team that created protocol buffers.
- gridlockd 7y agoProgramming is fundamentally about the transformation of data and sometimes data is in such a shape that inevitably requires such code. Most of the time, you don't get to decide what shape the data is in. OOP just obfuscates this basic fact of programming life to the point where it's not obvious anymore. That is not a good thing, it's a huge waste of time. Favor plain data over "objects" and functions over methods. Favor plain SQL queries over ORM.