My node.js life improved dramatically when I stopped using the OO paradigms, and just wrote functions in native modules.
My node.js life improved dramatically when I stopped using the OO paradigms, and just wrote functions in native modules.
While I've never been a huge fan of this, it's also usually the least of my problems. On the plus side it makes dependencies between modules explicit which has raised some flags occasionally.
How would you for example deal with having a single database pool that doesn't automatically connect on startup (when requiring a class)?
You could make abstract classes with error-throwing methods, then extend from those for the implementation.
I think most Node people would think of that as extra boilerplate, though, since DI in Node frameworks usually exists as a side effect of other technical requirements rather than as a design goal in its own right.