Architecture Pattern

General information

"Architecture Pattern" refers to the general guidelines on which a software project is built, i.e. the files that are used, how they are grouped, the functions they should or should not include, etc.

One of the most used patterns is the Model-View-Controller Pattern (MVC Pattern) that is described below. Microsoft has developed a platform "ASP.NET Core MVC" that facilitates building web applications and APIs in the MVC Pattern.

MVC Pattern

The Model-View-Controller Pattern is a design pattern used for software architecture that divides an application into three functional parts, which are the Model, the View and the Controller:

Model

The Model is responsible for the logic of the data. It is the only entity that interacts with the database. So for example, querying or updating data from the database is done by the Model. Other than the database, it only interacts with the Controller.

All Models belonging to a webpage are found as .cs-files (named after the respective webpage) in the respective Models folder.

View

The View is responsible for the presentation of the data. It is the only entity that contains HTML, CSS and JavaScript code to specify the layout in which the data is presented to the User. It only interacts with the Controller.

All Views belonging to a webpage are found as .cshtml-files (named after the respective webpage) in the respective Views folder.

Controller

The Controller is responsible for handling the requests. It is the only entity that communicates with all other entities, Model and View, but also the User. So when a User sends a request, the Controller will:

  1. receive the request

  2. communicate with the Model to get (and if requested also update or delete) the necessary data

  3. send the data to the View who renders the data according to the specified layout before returning it to the Controller

  4. forward the returned presentation for the User to see

The Controller of a webpage is named after the superior directory that groups webpages belonging to the same category followed by the term "Controller" and is found as .cs-file in the Controllers folder together with all other Controllers of the project.

Video

Last updated