To Survive the Pyramid of Doom…
use the buddy system
In order for this function to give us the local high temperature for today, it needs to connect to a weather web service. We could halt the program while wait for the data, but that isn’t really efficient. Instead, we tell the function to return the data, or “call us back,” once it has the requested information.
Callback functions can be extremely powerful; but when nested, they quickly become the bane of a n00b coder’s existence. Nested callbacks create the dreaded Pyramid of Doom, as seen in this snippet of code from a home inventory app that we wrote today in class:
Creating programs with callback functions has reinforced the importance of test-driven development (we’re currently using Mocha, Chai, and Travis CI), code quality & debugging tools, such as Grunt and JShint, and paired programming. Without my programming buddy, @LizaHCarter, I’d be stuck nesting parenthesis in callback hell.