Separation Of Concerns: Example with A Nodejs-Fastify-MongoDB Stack

Separation Of Concerns: Example with A Nodejs-Fastify-MongoDB Stack

Separation of concerns: example with a Nodejs-Fastify-MongoDB stack. In this article we will go through some maintainability issues and techniques to avoid them, using a nodejs web server built with Fastify (web framework) and Mongodb (database) as example.

Building software that works is one thing, building software that last is another, especially when the code size increases rapidly together with the number of people involved in its development.

In this article we will go through some maintainability issues and techniques to avoid them, using a  nodejs web server built with  Fastify (web framework) and  Mongodb (database) as example.

Definition of the web service.

This particular service is a simple  CRUD store for movies, but for many web services, you can scatter in the same way their various components somewhere along a line:

diagram of web service components stack

The bits on the left are very common and have probably little added value for your specific application. The relative value of your service lies in the data you have/collect and what you do with this data (the business logic).

It is important to note that the borders between the layers are not strict and may vary for different projects.

For example, a team with high skills in RDMS can do data aggregation and statistical calculation within a SQL query/function while another team will chose to do the same in the application code, finding it easier to maintain and test.

However, separating the different concerns will ease the maintainability of the codebase anyway, that is what we are going to review here.

javascript fastify clean-code nodejs

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

4 Ways You Can Get Rid of Dirty Side Effects for Cleaner Code in JavaScript

4 Ways You Can Get Rid of Dirty Side Effects for Cleaner Code in JavaScript. Bugs are born in many ways. Creating side effects is one of them. Some people say side effects are evil, some say they’re not.

Who Else Wants to Write Clean JavaScript Code?

Who Else Wants to Write Clean JavaScript Code? 7 Tips to Make Your Coworkers Fall in Love With Your Code.

7 Tips to Write Clean JavaScript Code

Who Else Wants to Write Clean JavaScript Code? In this Javascript tutorial, you'll see 7 Tips to Make Your Coworkers Fall in Love With Your Code.

19 Simple JavaScript Coding Standards to Keep Your Code Clean

JavaScript coding standards for improving the quality of your code.This is important due to JavaScript being a dynamic language so using == might give you unexpected results due to it allowing the type to be different.

Top 5 Tips for Making Your NodeJS code Easier to Read

In this article, we’ll look at 5 tips for making your NodeJS code easier to read and understand. How to Make Your Node.js Code Easier to Read