2

Is the M (model) in MVVM equal to business logic + data? Or is it just supposed to be data/state for the view?

Background: In a project we use "model" as a name for an object that holds presentation data. I expect that to be wrong. In my opinion a class/structure that just holds presentation data or state should called e.g. "SomeData" or "SomeState" instead of "SomeModel".

1 Answer 1

7

In MVVM the Model is supposed to hold data and business/validation logic.

Taken from the Microsoft documentation on the pattern:

The model in MVVM is an implementation of the application's domain model that includes a data model along with business and validation logic. Examples of model objects include repositories, business objects, data transfer objects (DTOs), Plain Old CLR Objects (POCOs), and generated entity and proxy objects.

1
  • 5
    And as a footnote: the VM is the View Model – the data that is currently being shown or manipulated in the View. What OP called the “model” or “presentation state” is most likely a View Model. Or perhaps a presenter, if they're doing MVP instead.
    – amon
    Jan 23, 2018 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.