Originally published on https://github.com/m-rec/c325017f9e66db9320f99fdced6ac3d66abc9212
Clone the project, run the unit tests and install the app
$ git clone https://github.com/m-rec/c325017f9e66db9320f99fdced6ac3d66abc9212.git mercari-jmfayard
$ cd mercari-jmfayard
$ ./gradlew testDebugUnitTest installDebug
You can also open the project in Android Studio
As can be seen in the screencast, the layouts are as simple as possible and thus do not respect yet all the UX requirements
This is because I choose Scenario B : A base for an app that will be developed and maintained for a long time
The easiest place to on-board a new developer is to ask them to polish the UX according to the detailed requirements that we have thanks to the mockups etc… What that require is to decouple the View from the logic of the app as cleanly as possible and I did took care of that.
Specifically the new developer should have to modify only
-
the class MercariDisplay.kt
-
the layouts mercari_screen.xml and mercari_item.xml
A big reason why Android developpment seems so hard is that we follow blindly all the good practices, especially all the recommandations from the Android team.
Actually, a third of those "good practices" are actually always good, a second third is good in some projects but not yours, and a third is just bad.
So I believe in ruthlessly eliminating complexity by applying those two principles
- KISS
-
Keep It Simple And Stupid
- YAGNI
-
You Ain’t Gonna Need It
Specifically here:
-
I use Coroutines that are beautifully simple for network stuff instead of RxJava or worse (AsyncTask, Service, …)
-
I have no need for Fragments, Bundles, Multiple Activities, Intents, Navigation Component, Service, ViewPager, …
-
I use a Single Activity architecture with the MVP pattern. For that, I use Magellan and in practice this project is based on my own sample https://github.com/jmfayard/android-kotlin-magellan
-
In the MVP pattern, my presenter is MercariScreen.kt. This presenter is persistent in memory which makes lot of usual Android problems disappear. It is a normal Kotlin class, not tied to the Android Framework but who knows how to recreate its
View/MercaryDisplay
whenever the android lifecycle needs it
Since I am choosing scenario B, I put some things in place that will avoid my team to waste lots of time in the future:
-
I have setup unit testing and would enforce it for new code
-
Dependency management and looking for new dependencies versions is handled by my Gradle plugin https://github.com/jmfayard/gradle-kotlin-dsl-libs
-
I have setup the Gradle buildScan plugin that makes debugging build problems much more easier
-
I have setup the project Ktlint, An anti-bikeshedding Kotlin linter with built-in formatter