jeudi 19 juillet 2018

How to define model in a Master Detail Android app?

Every new project I start I have the same dilemma - how to handle Master-Detail data.

Let's say we have a standard Master-Detail pattern in the client app, where data is obtained from a REST API.

For example: Movies in the list are obtained through a GetList Rest API method which returns a list of Movies (DTO) with following properties:

  • id
  • title
  • thumbnail image
  • number of likes

Movie (DTO) in the details is obtained in a GetDetails Rest API call, with following properties:

  • id
  • title
  • director
  • date
  • language
  • number of likes etc.

The application needs to support offline mode, so there should be some local persistence, usually SqlLite, Room, or similar.

How do you model this data - do you have one Movie model class, and also a Movie table in the local storage, or do you treat it like two different types - MovieSummary and MovieDetails?

Do you even have a model in the client or do you just treat data as server DTO and just save current state?

Aucun commentaire:

Enregistrer un commentaire