An attempt to formalize JS development patterns

In 2015 Alexander Kondovchief engineer at News UKassumed Node.js how he looked at it JavaScriptThe ability to run in both browser and server is a key feature his team could enable. Based on his learning, he created the Tao of Node, which contains “tested rules and guidelines for building better applications.”

The permissiveness of nodes to reuse libraries, logic, and types across front-end and back-end applications led to the archetype of the “full-stack developer”: an engineer skilled enough to work on every part of the application to work he needs. Its focus on freedom and flexibility, not imposing strict coding standards or application structures, led it to conclude that each Node application seems to follow a different approach.

Building on his experience building various applications, he established a set of principles for an improved experience when writing Node applications.

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

InfoQ: Hi Alex. Thank you for taking the time to answer our readers’ questions. Can you describe your responsibilities and what motivated you to write this? Tao of the Knot?

condov: I am currently Senior Engineer at News UK, leading two of our Enabler teams creating libraries, developer tools and infrastructure for the rest of the engineers. My day-to-day duties aren’t very different from those of other developers, but I read and review more code than I write.

The goal behind Tao of Node was to formalize some of the common patterns I’ve used successfully in my career and save some time for the engineers who are just starting out. The node ecosystem values ​​freedom and choice, but sometimes it helps to have a set of core principles. Good moves put you in good positions, similar to chess.

InfoQ: Nice to read, but lengthy. The five most important takeaways for the reader? Any plans to make them enforceable through linters?

condov: Firstly, I think the application structure is crucial, so I would advise people to always organize their node services around components and domain entities, rather than technical responsibilities.

Second, merge related functionality and create nested modules.

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

Fourth, for performance, make sure you don’t block the event loop with intensive operations and you’ll solve most of your speed worries.

Finally, don’t worry about database changes when it comes to abstractions—if you ever need to change an application’s storage in production, the data it contains should be your biggest concern.

Although I’ve considered making one ESlint plugin, in the end I preferred to keep them as guidelines. That way I don’t limit people’s creativity as a lot of the rules are contextual.

InfoQ: How would you recommend putting theory into practice? How can it be implemented in existing projects?

condov: Bit by bit. Start by improving the structure, as this will require the least amount of refactoring. Codebase reorganization mostly only requires import path changes. With a better structure, you can approach each module individually, separating levels and splitting the logic. Much like a messy shelf, everything needs to come out before you can rearrange it.

A possible side effect of refactoring can be the degradation of code quality. Once the clutter is cleared, you’ll have a more organized and productive application to work with.

InfoQ: Looking at the JS ecosystem, what would be your biggest concern? what would you need

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

Many new features have been added to JavaScript recently. That’s not bad in and of itself, but bloating the standard library isn’t the way to go. The need for backwards compatibility leads to a language that is constantly growing. JS’ support for both functional and object-oriented paradigms makes it attractive for engineers but can be very confusing for newbies.

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 managing the toolchain – typescripttests, linters, etc.

Seven years later node 1.0.00Alexander Kondov celebrated this anniversary by releasing The Tao Of Node, an idiosyncratic set of principles intended to create a unified approach to developing backend applications in JavaScript.

Meanwhile the once browser-only language enjoyed growing popularity and was awarded the silver medal Status of DataDog without server report, while GitHub’s language stats suggest it is one of the main languages ​​used in the first quarter of 2022.

As its popularity grew, so did JavaScript’s responsibilities, with The Tao Of Node attempting to normalize the various approaches that Node’s flexibility enabled.

Comments are closed.