3 ms·
Well in addition to not having a problem with callback hell I also haven't used a debugger in more than three years, so I guess I'm just weird. As I said I lik
by NathanKP 13y ago
Well in addition to not having a problem with callback hell I also haven't used a debugger in more than three years, so I guess I'm just weird.
As I said I like to write unit tests with my named callbacks. This allows me to test the callbacks as well as the root level functions that make use of these callbacks to ensure that everything is working perfectly.
When I follow this model it is extremely rare that I ever encounter any issues that would need a debugger, and if a problem does arise somewhere the relevant unit test can quickly expose which callback is having a trouble, and precisely what is wrong.
I'm not saying callbacks are perfect. My goal is just to share my technique for organizing my code in Node which I feel has led to some very well organized, testable, and maintainable code.
- gambler 13y agoWhen someone gives you a sufficiently large codebase written by other people and asks why when they click A they get B, you have two options: 1. Read the code and try to reason about it. 2. Fire up the debugger and replicate user actions. Guess what? Callbacks in JS make option #1 significantly harder, since they are, essentially, runtime weakly typed mechanism for code composition.
- pjmlp 13y agoThis is a common issue. I guess people that state they are fine with it, never worked on the typical enterprise codebases, done by several consulting firms along the years. When one works on their own code, or startup elite programmer style, everything is easy.