Node.js
is a JavaScript runtime built on Chrome's V8 JavaScript
engine.
Node.js
uses an event-driven
, non-blocking I/O model
that makes it lightweight and efficient.
Node.js
package ecosystem, npm, is the largest ecosystem of open source libraries in the world.
The Node.js core should be kept as small as possible. The ecosystem of modules living outside the core.
Don't Repeat Yourself (DRY)
In Node.js, one of the most evangelized principles is to design small modules
, not only in terms of code size
, but most importantly in terms of scope
.
Small module is also considered to be the following:
- Easier to understand and use
- Simpler to test and maintain
- Perfect to share with the browser
Node.js modules usually have the characteristic of exposing only a minimal set of functionality.
Keep It Simple, Stupid (KISS)
"The design must be simple, both in implementation and interface. It is more important for the implementation to be simple than the interface. Simplicity is the most important consideration in a design." (c) Richard P. Gabriel
Principles from Isaac Z. Schlueter (source)
- Write modules that
do one thing well
. Write anew module
rather thancomplicate an old one
. - Write modules that
encourage composition
rather thanextension
. - Write modules that handle data
Streams
, because that is theuniversal interface
. - Write modules that are
agnostic
about thesource of their input
or thedestination of their output
. - Write modules that
solve a problem you know
, so you can learn about the ones you don’t. - Write modules that are
small
. Iteratequickly
. Refactorruthlessly
. Rewritebravely
. - Write modules
quickly
, to meet your needs, with just afew tests for compliance
. Avoid extensive specifications. Add atest for each bug you fix
. - Write modules
for publication
, even if youonly use them privately
. You willappreciate documentation in the future
. Working
is better thanperfect
.Focus
is better thanfeatures
.Compatibility
is better thanpurity
.Simplicity
is better thananything
.