dimanche 28 novembre 2021

Model classes vs Model in MVC

Does the model in MVC contain both business logic (algorithms and stuff) and the classes that are mapped to entity tables in databases? Those mapped classes are called model as well, specifically, because they model some data. My confusion is this: Does model contain the business logic? or is it just entities? It turns out that it contains, from Mozilla docs: Model: Manages data and business logic.

I got confused by how Java Spring projects are structured. There are controllers, service (business logic), repository(connection to database, aka DAOs) and model classes (Classes of objects that are received by controller and often mapped to database entities). Let's map this to MVC "components":

View - Not in a spring app;

Controller - Rest controller (or just Controller, depending on how you want to structure your app);

Model - Services, Repositories, Model classes (???).

I am confused here, that we have model in both left and right sides.

Thanks.

Aucun commentaire:

Enregistrer un commentaire