Hacker News new | past | comments | ask | show | jobs | submit login

You misunderstand me, I think. Callback spaghetti is different from complex code that uses lots of callbacks.

I'm not saying you don't need to have a series of nested callbacks to do things, I'm saying you should hide these behind the appropriate abstractions for the task you're writing.

In your case the bullet points listed are exactly those layers of abstraction.

The request handler processes the form and calls the S3 layer for each file. The S3 layer then calls the APIs and passes off the responses to the XML parsing layer - which gives it back a useful JS object detailing the response, the API layer then provides a response to the request handler which formats the response and sends it to the client.

The workflow I'm implementing in Node is even more complicated than this, but good use of abstractions and control flow libraries[1] means that it's extremely rare for any code to be indented more than 5 blocks.

[1] https://github.com/caolan/async is my lib of choice, but plenty of other suitable choices exist.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: