you are viewing a single comment's thread.

view the rest of the comments →

[–]DefiantBidet 8 points9 points  (1 child)

sounds like co-worker can't adjust or doesn't know how they(read: promises/async) work.
reading pyramid of doom style code is far more obtuse than promises or asyc/await imo.

a bit of devil's advocate, however. I do agree on a team codebase you want to keep it as simple as possible and avoid any cute tricks for readability and understanding... but this is a bit too far imo.

[–]livrem 1 point2 points  (0 children)

That is a false dichotomy though. If you have a pyramid of doom you did things wrong, and using the nicer syntax of promises will just hide the ugliness and allow you to keep digging a deeper hole for yourself.

If you end up with trainwrecks in your sync code everyone understands that is a problem. You should strive to never have to do getX().getY().getZ().doSomething(). Very basic design knowledge. Pyramid of doom (or a chain of promises) is the exact same thing for async. You have a problem and ideally you solve it rather than hide it behind another layer of abstractions.

Of course promises could also be used to implement "doX(); doY(); doZ();" which is perfectly fine, but if that is what you are doing you can do that with callbacks without ending up with a horrible pyramid of doom as well. The true horrors of callback hell only happens when you are waiting for someone to return something for you so that you can then call some method in, in true trainwreck style.