Full-Stack Web Development with Vue.js and Node

(singke) #1
Building an Express Application Chapter 2

It is not necessary to implement the MVC platform in the application we build. The


JavaScript is pattern agnostic, which means we can create our own folder structure. Unlike
other programming languages, we can choose whatever structure is easiest for us.


Why MVC?


There are a lot of benefits that are added when we implement an MVC architecture into our


application:


Clear segregation of business logic and views. This separation allows us to reuse
the business logic throughout the whole application.
The development process becomes faster. This is obvious since the parts are
clearly separated out. We can just add our views to our views folder and add
logic inside the models folder.
It is easy to modify existing code. This is very handy when multiple developers
are working on the same project. Anyone can pick up the application from
anywhere and start making changes to it.

Changing the folder structure to incorporate MVC


Now that we know enough about MVC, let's modify the folder structure of the application


we created, called express_app. First of all, we need to create these three folders in the


root directory. There is already a views folders so we can skip that. Let's go ahead and


create models and controllers folders.

Free download pdf