Reddit Reddit reviews Node.js Design Patterns: Master a series of patterns and techniques to create modular, scalable, and efficient applications

We found 2 Reddit comments about Node.js Design Patterns: Master a series of patterns and techniques to create modular, scalable, and efficient applications. Here are the top ones, ranked by their Reddit score.

Computers & Technology
Books
Computer Programming
Software Design, Testing & Engineering
Software Development
Node.js Design Patterns: Master a series of patterns and techniques to create modular, scalable, and efficient applications
Check price on Amazon

2 Reddit comments about Node.js Design Patterns: Master a series of patterns and techniques to create modular, scalable, and efficient applications:

u/Taurath · 4 pointsr/node

I'd recommend node design patterns (http://www.amazon.com/Node-js-Design-Patterns-Mario-Casciaro/dp/1783287314) for reading on the subject.

In general I make everything a module - from the router to the endpoint logic to the database integration. Not a full on NPM module, unless I'm doing microservices, but each module will have its own tests and generally not be coupled to anything else except its dependencies - it should stand on its own within reason, because then it'll be more testable and maintainable. The module system in node works very nicely for this, since you can just export the "public" functions and hide the private ones much like classes in a traditional OO language.

Also important is if you're using large libraries to make wrapper modules. Even if I don't ever plan to move off of mongoDB for my database module as an example example, I still expose my own interfaces rather than the direct library ones so if I ever need to swap it out its a simple method of updating that module, not any of the calls to it. Refactoring module interfaces often is what gets you in more trouble, so that lets me keep my changes in one place.

The rest you can get through guides and reading... error handling and asynchronous flow control (parallel, series, combinations) are the biggest hurdles in node. I use just callbacks and async because I feel its a little easier to reason about, but promises and async/await work as well. Whatever you use stick with it. Always handle errors - an uncaught exception will take down your server. Expect it to happen even if your code is rock solid, and have a plan for spinning down gracefully (uncaught exception handlers - read recent articles there's a lot of bad older ones out there) and restarting the process (forever, pm2, other process managers).

u/TheSlimRealShady · 3 pointsr/node

Javascript can be a really tricky language to truly understand. It's known as the "most misunderstood language" for a reason, and that's because for the most part, developers have been fine with just knowing the basics and coming up with solutions using limited knowledge. Your difficulty with getting the ball rolling with Node is almost definitely due to a lacking understanding of the Prototype-based nature of Javascript, and all the unique characteristics of a language as a result of Prototypes. I also started Node with a Java (OOP) background, and ran into difficulties right away. Here's how I approached Javascript (and Node) and saw quick results (don't get me wrong, there's a lot of work involved, but you'll notice how much more sense the language makes to you rather quickly).

  1. Learn the very basics of JS however you want. I'm assuming you know enough to use functions, loops, conditions, etc. all the basics. If not, I recommend the first 4 chapters of Eloquent Javascript.
  2. Take Udacity's Object-Oriented JavaScript Course (free).
  3. Buy and read the entire YDKJS Series. Don't just read through it, but annotate a lot. Even for smaller bits of code, make sure you understand why things work the way they do.
  4. As you're reading YDKJS, start studying Node.JS libraries that interest you. Try to make sense of what the developer is doing and how everything works together.
  5. Read, annotate, and practice with chapters 5 - 11 of Eloquent Javascript.
  6. Read all the way through Node.JS Design Patterns.
  7. Continue to study and extend libraries. You can find inspiration for projects by reading through, understanding, and experimenting with open source libraries (Github is your friend).

    This method turned me from your average Javascript kiddie to a solid JS wiz. Might work for you too.