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".

6

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.

  • 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 '18 at 15:15

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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