Tuesday, April 14, 2020

How to Implement a JavaScript Project Using Express with ORM (Sequelize), MVC model, OO (Object-Oriented programming) and Design Patterns?



>PROBLEM

The usual approach of JavaScript programmers makes no use of object-oriented programming, or mixes both styles, the "function-oriented" approach, common on this kind of platform due to its origins from browser's programming — old times!  Please, do not take this for functional programming that it is something different.
Just because it is used "functions" instead of classes doesn't mean that it is necessarily functional programming.

The old approach although fast and easy in some way, becomes cumbersome over time, turning out a project with difficult maintenance, cohesion issues, and tangled code.

ES6 offers a marvelous object-oriented implementation, easy and practical.

ORM is a key concern to decouple persistence.
Persistence pattern turns code concise and reusable extending resources and providing cohesion.

Another side effect is that ORM is more secure.
It may protect against SQL injection.

After Node.js, JavaScript becomes a "grown-up boy", having its own platform to run full implementation across a project, and no more a "browser's language".

How to use OO/ORM/DAO patterns with JavaScript/Node.js?


>SOLUTION

Since this kind of approach is relatively new for JavaScript programmers and not very popular although used by seniors developers, it is easier than supposed.


In order to become accessible for everyone who intends to evolve adopting the ES6's OO resources, the subject was split into pieces ("
Jack methodology") to turn things easier — it was created a step-by-step tutorial.


The code isn't a definitive version for production, but a good start to get the grips of it.

NODE.JS: SEQUELIZE TUTORIAL SERIES
(Revision 2022 using Node.js v.16)


Enjoy!













No comments:

Post a Comment

eclipse: java: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" or Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

  >PROBLEM Using Eclipse, you try to run a simple logging test using "org.slf4j.Logger" like the sample below: package Test; im...