Hello
Callback hell has been mentioned a few times (mainly by Nathan) and it is something that has been bugging me recently because I have indeed fallen into this trap. It is also known as the "pyramid of doom" because your code can end up looking like an ever increasingly complicated list of nested function calls.
However, mainly because Sails uses it "out of the box", I have educated myself in the use of "Promises". Promises allow you to write your asynchronous code in a synchronous way, such that callback hell can be eliminated.
I won't go into the details here, but if you are interested, look up
https://github.com/kriskowal/q
Waterline ORM also uses a promises library called "bluebird":
http://bluebirdjs.com/docs/getting-started.html
I have refactored a lot of horrific code now that I have a grip on this technique.....promises are beautiful thing!
Kevin
________________________________
NOTICE: The information in this electronic mail transmission is intended by CoralTree Systems Ltd for the use of the named individuals or entity to which it is directed and may contain information that is privileged or otherwise confidential. If you have received this electronic mail transmission in error, please delete it from your system without copying or forwarding it, and notify the sender of the error by reply email or by telephone, so that the sender's address records can be corrected.
--------------------------------------------------------------------------------
CoralTree Systems Limited
25 Barnes Wallis Road
Segensworth East, Fareham
PO15 5TT
Company Registration Number 5021022.
Registered Office:
12-14 Carlton Place
Southampton, UK
SO15 2EA
VAT Registration Number 834 1020 74.
As an Amazon Associate we earn from qualifying purchases.