Home > Blockchain >  Division of components in MVVM?
Division of components in MVVM?

Time:04-11

I want to know if my understanding of MVVM is right. Let's say I want to develop an application for say resort reservations:

  • The Views would contain the UI for the reservation information, so that the user can search for reservation, see rooms and whatever

  • the ViewModel would control the data from the views, like the user's name, data of reservation and whatnot, by that I mean read the user data from the textboxes and so on

  • the Model would implement the user and reservation class

Are my assumptions correct?

CodePudding user response:

Yes. Views are everything that your user sees and can interact with, and they should be as "dumb" as possible, meaning no business logic should be in that layer.

Viewmodels should handle all data loading/processing and should pass that data to the views. So if you want to fetch data from db, you don't call it from view but go through viewmodels. Also when you are writing tests you should test viewmodels. And models are just a data representation like User, Room, Hotel.

  • Related