BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News The Tao of Node: an Attempt to Formalise JS Development Patterns

The Tao of Node: an Attempt to Formalise JS Development Patterns

Bookmarks

In 2015 Alexander Kondov, principal engineer at News UK, adopted Node.js as he considered its JavaScript’s ability to run both in the browser and the server an important feature that could enable his team. Based on his learning, he created the Tao of Node, which "contains proven rules and guidelines to build better applications."

Node’s permissiveness to reuse libraries, logic, and types across front-end and back-end applications gave rise to the "full-stack developer" archetype: an engineer skillful enough to work on any part of the application they are needed. Its focus on freedom and flexibility, not imposing strict coding standards or application structures, brought it to point that each node application seems to follow a different approach.

Building on his experience building various applications, he laid down a series of principles for an improved experience while writing node applications.

InfoQ reached out to him to find out more about these principles.

InfoQ: Hello, Alex. Thank you for taking the time to respond to the questions for our readers. Can you describe your responsibilities and what motivated you to write the Tao Of Node?

Alex Kondov: I’m currently a principal engineer at News UK, leading two of our enabler teams that are building libraries, developer tools, and infrastructure for the rest of the engineers. My day-to-day responsibilities are not that different from that of any other developer, but I read and review more code than I write.

The goal behind Tao of Node was to formalize some of the common patterns that I’ve used successfully in my career and save some time for the engineers who are just starting. The Node ecosystem values freedom and choice but sometimes having a starting set of principles helps. Making good moves puts you in good positions, much like in chess.

InfoQ: Nice read, but lengthy. Top five takeaways for the reader? Any plans of making them enforceable through linters?

Kondov: First, I think application structure is critical, so I’d advise people to always organize their Node services around components and domain entities rather than technical responsibilities.

Second, co-locate related functionality and create nested modules.

Third, establish layers between the transport, domain, and data access logic.

Fourth, for performance, make sure you’re not blocking the event loop with intensive operations and you’ll solve most of your speed worries.

Last, don’t worry about database changes when it comes to abstractions - if you ever need to change the storage of an application in production, the data in it should be your biggest worry.

Even though I considered creating an ESlint plugin, in the end, I preferred to keep them as guidelines. In that way, I don’t limit people's creativity, as many of the rules are context-dependent.

InfoQ: How would you recommend bringing the theory into practice? How to implement it on existing projects?

Kondov: Piece by piece. Start by improving structure; it involves the least refactoring. Codebase reorganization requires mostly just import path changes. With a better structure, you can tackle each module at a time, separating layers and splitting logic. Similarly to a messy shelf, everything needs to go out before you can rearrange it.

A possible side effect of refactoring might be the decrease in the code’s quality. Once the mess is cleared up, you’ll have a more organized and productive application to work with.

InfoQ: What would be your biggest concern when looking at the JS ecosystem? What would you need?

Kondov: Node.js is a powerful tool that I would use for any application that doesn’t require heavy computation or manipulation of large data structures. It particularly shines when it comes to high-volume IO, but it can easily get winded if used for a problem that it cannot solve. Its community is quite resourceful, but it definitely needs some standardization, especially for tooling.

Much new functionality was added to JavaScript lately. That is not inherently bad, but bloating the standard library is not the way to do it. The need for backward compatibility results in a language that keeps growing. JS’ support for both functional and object-oriented paradigms makes it appealing for engineers, but it can be very confusing for newcomers.

Tao of Node is my attempt to formalize some of the development patterns, but the JS community, in general, can benefit from a single tool that manages the toolchain - TypeScript, testing, linters, etc.

Seven years after node’s 1.0.00, Alexander Kondov celebrated this anniversary by publishing The Tao Of Node, an opinionated set of principles that should create a uniform approach for developing backend applications in JavaScript.

In the meantime, the once browser-only language grew in popularity and was awarded the silver medal by DataDog’s state of serverless report, while GitHub’s language statistics point to it as being one of the main languages being used in the first quarter of 2022.

In accordance with its popularity, JavaScript’s responsibility also grew, The Tao Of Node trying to normalize the various approaches that node’s flexibility allowed to appear.

About the Author

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT