Chapter 3. Node programming fundamentals


This chapter covers

  • Organizing your code into modules
  • Coding conventions
  • Handling one-off events with callbacks
  • Handling repeating events with event emitters
  • Implementing serial and parallel flow control
  • Leveraging flow-control tools

Node, unlike many open source platforms, is easy to set up and doesn’t require much in terms of memory and disk space. No complex integrated development environments or build systems are required. Some fundamental knowledge will, however, help you a lot when starting out. In this chapter we’ll address two challenges that new Node developers face:

  • How to organize your code
  • How asynchronous programming works

The problem of organizing code is familiar to most experienced programmers. Logic is organized conceptually into classes and functions. Files containing the classes and functions are organized into directories within the source tree. In the end, code is organized into applications and libraries. Node’s module system provides a powerful mechanism for organizing your code, and you’ll learn how to harness it in this chapter.

3.1. Organizing and reusing Node functionality

3.2. Asynchronous programming techniques

3.3. Sequencing asynchronous logic

3.4. Summary