• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

MVVM pattern

 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
I am starting with android and trying to understand the MVVM pattern by making a small app(very basic with hard-coded data in a form of String[] array i.e. no use of database ).I am implementing recyclerView +data binding+MVVM pattern.I am not able to understand the exact working of MVVM.
Can you suggest some resource where I can get something similar to what I am trying to make.OR any resource which can provide me a clear understanding of this whole concept OR If any one Can explain it to me in brief(not including it's definition please)and I am using android from past 4 days only so kindly stick to the basics while explaining which can help me in understanding(Request not to use any complex terms. Beacause I might get confused).It's urgent I have already wasted two days but still not able to understand this pattern.
Thanks in advance
 
Saloon Keeper
Posts: 10308
217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, there is the Model, the View, and the ViewModel. The Model is the in-memory representation of your problem domain. This is where you perform application logic. A View consists of the code that is necessary to display some information to the user, usually a page template and some client-side logic. A ViewModel contains the data that you want to display in a View. It contains only a part of the data in the Model, and only the part that a particular View is interested in. It contains no logic other than what is necessary to transform the data in the Model to a format that the View understands.

Example, if you have a student registration system that also keeps track of what classes a student takes and what grades they scored on exams, it might have a page where a student can take a look at their grades, and it could have a different page where they can edit their personal information. The Model consists of all classes that represent the core of the application, such as Student, Course, Exam, Grade, etc. The ViewModel for the page where the user can see their grades would only consist of a list where each item holds the course name and a grade. The View for that page consists of the graphical components that are necessary to display the list of grades. The ViewModel for the personal information page holds parts of the Student class, and maybe parts of other classes that you want to display on such a page. The View for that page consists of fields where that data can be displayed and edited.

In simple terms:

WhatDescription
ModelEverything interesting the application can do.
ViewModelThe information you want to display right now.
ViewHow the information is displayed.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!