Notice something not on the list of best practices: documentation. While Node itself has excellent docs (for the most part), the Node community is <i></i>terrible<i></i> about documentation. If you're lucky you'll get a single README.md file with the basics covered.<p>Pick any category of module and there's a good chance the most popular modules have little documentation; certainly nothing close to comprehensive.
Just a few comments:<p>> if (!(this instanceof MyClass)) return new MyClass();<p>If you really want, just throw an exception and kill the program at compile time. Catch programming errors in testing and not do some magic to 'autocorrect' code.<p>> var localFile = fs.createWriteStream('localFile.tmp');<p>Always catch 'error's in stream objects. Otherwise, it might thrown an exception at runtime.<p>localFile.on('error', /* do something */)<p>Coding style:
In most cases if you write you code properly, you don't need to nest more than 3-4 levels. If it gets deeper split it out into separate functions. Otherwise, it's a perfect job for async.series.
I'm coding a fairly large application in Node and have never heard of EventEmitter or Streams. Does that mean I'm doing something wrong? The impression I get from the article is that it's such a fundamental patterns that every serious application should use it.
I'm personally not a huge fan of the eventemitter for cases where an event is only ever emitted once (an sql query is done or similar).<p>For 2.0 of Sequelize we've moved almost the entire codebase to promises and will encourage users to interact with Sequelize with promises.
Not that long ago, anonymous functions and closures were the height of fashion in every language.<p>Now the recommendation is to name your functions and avoid closures. This brings us right back to what C programmers have been doing with function pointers since forever. Not that this is such a bad thing.
When they say 'avoiding closures', how does that relate to functions in your module? Your module is often exported as a function, so are they suggesting that every function be exported?
I suspect I'm not understanding the logic behind 'stack based'. Why is it better to have your functions not contain other functions (or is it not be contained?)