News for hackers. Stuff that matters.
Re:TypeScript 3.7 Beta by manojlds on Wednesday October 02, 2019 @03:32AM (#21134110)
Mostly it's a code smell though

https://en.m.wikipedia.org/wiki/Law_of_Demeter

Re:TypeScript 3.7 Beta by Vanit on Wednesday October 02, 2019 @03:50AM (#21134195)
4 chains is like reaching into an XHR response to pull out the success result, so I wouldn't say that's necessarily a smell.
Re:TypeScript 3.7 Beta by gridlockd on Wednesday October 02, 2019 @05:15AM (#21134595)
Programming 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.

Re:TypeScript 3.7 Beta by zhirzh on Wednesday October 02, 2019 @04:53AM (#21134496)
I'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?

Re:TypeScript 3.7 Beta by jiofih on Wednesday October 02, 2019 @02:44PM (#21139524)
Tell that to the team that created protocol buffers.
Re:TypeScript 3.7 Beta by mattmanser on Wednesday October 02, 2019 @04:33AM (#21134407)
Not really, especially when you're working with external APIs. That's when I find myself using a lot of this type of code.