commons-app / apps-android-commons

The Wikimedia Commons Android app allows users to upload pictures from their Android phone/tablet to Wikimedia Commons
https://commons-app.github.io/
Apache License 2.0
1.03k stars 1.23k forks source link

Introduce Room DB abstraction layer to our app #1043

Open maskaravivek opened 6 years ago

maskaravivek commented 6 years ago

For starters, heres an article explaining room https://medium.com/google-developers/7-steps-to-room-27a5fe5f99b2

I recently used Room in one of the projects and found the following advantages.

It would be great to have thoughts from others. @psh @misaochan

psh commented 6 years ago

The TL;DR - yes, I like Room but I think there are some fundamental things to address on the path toward using it.

Most of the advantages you cite can be derived from any modern ORM - I (and my team) evaluated

I really liked the generated code from GreenDAO - very efficient and by far the best performance - and the RxJava integration of sqlbrite got our attention too. I ended up recommending Room to our client based on a sense of longevity it brings and its small size - it adds very little to the app (method count or physical size) and smoothly integrates with our app's legacy Sqlite database installed on user's devices (precluding Object box and Realm from our team's evaluation)

Back to the Commons App again - we have a couple of PR - #1023 ("Extracted and tested the database interactions from Category") and #1022 ("Extracted and tested the database interactions from ModifierSequence") - that start us on the road toward using a tool like Room. Note: #1026 ("Extracted and tested the database interactions from Contribution") has already been merged.

Bugs like #894 ("Media details lost on device rotation") tell me that we need to address some core architecture. The contributions activity and the nearby activity both have complex models attempting to be shared across multiple fragments and activities. The ContributionsActivity relies on the somewhat arcane notification mechanism from Content Providers, Cursors and content URIs. There's complexity to address and bugs to fix.

Room is a very pretty band-aid being applied to a broken leg - definitely great at what it does, but only part of the overall picture.