The concept of a model in terms of, for example, MVC or ORM is quite common. But what is it?

Let's say we have a users table. Previously, it seemed to me that the model would be a specific row of this table, which is wrapped in a User class. After reading about the DAO pattern, I'm a little confused. Here, the User class is a bin ( bean ), and the model is the entire table.

Do I understand correctly ?

  • one
    habrahabr.ru/post/321050 - here's a good explanation of what a model is. - Monk
  • one
    Both. A model is a piece of code that simulates a subject area. - VladD

1 answer 1

The model, in the case of MVP patterns, MVC is a layer that represents the logic of your project, is abstracted from any details of the UI, data conversion tasks, etc.


To make it clearer, an example (using the MVP pattern). There is a calculator with GUI and three implementation classes:

View.java - will be responsible for the display (creates a window, sets fields, etc.) Presenter.java - will be responsible for the redirection of clicks and received data in Model.java .

Model.java - counts the received data and returns to Presenter .


How it works:

The user enters the numbers 2, 10 and clicks "Add." View gives Presenter data, it converts it (adds to the MathAction object) and gives it to the Model . Model counts and returns the result. Presenter , which receives the result in the form of an object, extracts from it a number with the result and tells View to display it.