getodk / collect

ODK Collect is an Android app for filling out forms. It's been used to collect billions of data points in challenging environments around the world. Contribute and make the world a better place! ✨📋✨
https://docs.getodk.org/collect-intro
Other
715 stars 1.37k forks source link

Standardize dependency injection across Collect #2471

Closed jd-alexander closed 5 years ago

jd-alexander commented 6 years ago

Problem description

So we are actively working on making more components within Collect loosely coupled so that we can increase the testability of the app as a whole and also the ability to test individual components. We could say that Dagger is one of the major proponents of this as it provides us with a DI solution that has been tested and proven by our industry to accelerate proper TDD workflows. Therefore it's usage throughout the app has been on an increase as we are constantly building out complex feature requirements that have several dependencies and scopes and this is the reason I think we should begin an official exercise of making all of this standard within the app and contribution guidelines.

To begin this, I am asking @shobhitagarwal1612 to do a review of the best approaches we can take to accomplish this and if we would be able to mobilize enough resources to ensure that these changes would be contributor friendly! We have already started using most of these concepts throughout so doing this would be a great way to get everything formalized!

Will update this with reading resources and more of my thoughts/research when I finalize them.

jd-alexander commented 6 years ago

@opendatakit-bot label "needs discussion"

lognaturel commented 5 years ago

In https://github.com/opendatakit/collect/pull/1871#issuecomment-435341476, @seadowg mentioned that he has DI/Dagger experience and is interested in helping clean things up and provide a model and framework for others to keep building in a consistent direction. It sounds like he and @shobhitagarwal1612 have started conversations around that.

I think what is really important is to make sure that there are resources provided to help contributors get a consistent mental model of the goals and structure of the architecture (what scopes to use when, where to inject non-Activity and non-Application classes, etc). There was already some of that (e.g. the comments at the top of AppComponent and AppModule), but it didn't get enforced (mostly by me, sorry!).

@seadowg, @shobhitagarwal1612 it's sounding like you think an illustrative example is a good way to start?

seadowg commented 5 years ago

@lognaturel @jd-alexander sorry I completely forgot to reply in this thread (we had discussed in #1871). I'm finishing up a PR with a reworked configuration for Dagger and some documentation around patterns.