Chapter 16 P 301 Packages Matching Hierarchy

The book hierarchy is (bottom to top):

  1. Model 2. Room 3. DA 4. Repo 5. ViewModel 6. UI

The packages sequence stated as:

  1. db 2. model 3. repo 4. ui 5. viewmodel

The packages order does not correspond to the hierarchy. It seems it should be as follows:

  1. model 2. db (Room and DA) 3. repo 4. viewmodel 5. ui

The order of setup is presented, but I would suggest the ‘flow’ is highlighted as:

  1. Model (Bookmark: entity class)
  2. DAOs (BookmarkDao: SQL queries against Bookmark)
  3. DB (PlaceBookDatabase: ref Bookmark and BookmarkDao)
  4. Repo (BookmarkRepo: link PlaceBookDatabase, BookmarkDao and Bookmark)
  5. ViewModel (MapsViewModel: ref BookmarkRepo to add a Bookmark from a Google Place object and image)
  6. UI (get Google Place and pass to ViewModel)

Thanks.

@tblank Do you have any feedback about this? Thank you - much appreciated! :]

Hi @mazen_kilani,

Thank you for your thoughts on this topic. We will take this into account for the next edition and look at providing more consistency in the way the architecture is presented.

Regarding the flow, we are showing the concept that the DAOs are used directly by the Repo and that they in turn handle the data persistence. In the case of Room, you’re correct that the RoomDatabase references the DAOs. We will look at how this might be explained better in a future edition of the book.

Thanks,
Tom