mvvm concept in software design – model view view model?

864 views

I literally studied computer science and don’t understand this. I’m so frustrated.

In: Technology

3 Answers

Anonymous 0 Comments

Are you asking this purely out of curiosity or because of a job?

MVVM isn’t extremely popular in my experiences any longer, but older applications will use this design. It is very good for ‘Single Page Applications’. Here’s my explanation in comparison to MVC which I have alot of experience with. Hope it helps.

If you are familiar with the basics you know the model houses all of the fields/properties and typically a few type specific methods like maybe a ToString override. The view is merely the presentation, what the user will see. Here is where MVC and MVVM differ. .

In MVVM there is no controller. Most, if not all, properties on a model are bound to an object on the view. Example would be a text field called name. If the user types “Mike” on the view the model will get that information immediately. In MVVM the model will also be responsible for all event driven actions. If a user clicks Save for instance, the model will house atleast the entry point for this action. It essentially removes the need for a controller by inserting direct communication between the view and model and adding responsibility to the model.

MVC which I much prefer has a controller which house all of the ‘actions’. In essence a controller is constantly ‘listening’ for the user to do something. In this design there is no communication between the model and view. Model only houses the data. View only displays the data. The controller lies inbetween and does all of the work. For instance in this example if a user types the name “Mike” into the same textbox the model will have no knowledge of this until the controller is informed via an action on the view. A simple example is the user types into a text field on the view. A Save button is pressed which then passes the value in the text field to the controller. The controller will do something with that information, possibly update the model, and pass the new model to the view.

I know I didn’t explain this like you were 5 lol, but it’s not something a 5year old could understand. I know you didn’t ask this, but in my opinion MVC is the clear winner for all the applications I’ve worked on, however I have worked exclusively with Web Apps.

You are viewing 1 out of 3 answers, click here to view all answers.