collect
collect copied to clipboard
Make managing project dependencies more consistent
The idea here is to create a consistent way to create project level dependencies in objects that interact with multiple projects (like data services) to make it easier to write tests and to create ways of providing those dependencies.
This approach isn't completely finished. I've established the pattern, but some of our "providers" and their usages (like StoragePathProvider
) would need significant rework and the main thing I wanted to get to here was a route forward. In those cases I've deprecated previous ways of access dependencies so we can remove them gradually.
I've also added some helpers for data services so we can keep the implementation more consistent in the form of new extensions for AppState
.
Why is this the best possible solution? Were any other approaches considered?
I did initially look at using Dagger's "assisted injection", but I found this wasn't ideal. For instance, I'd end up with factories like this:
@AssistedFactory
public interface FormsRepositoryFactory {
DatabaseFormsRepository create(ProjectsDataService projectDataService);
}
There are two problems here:
-
DatabaseFormsRepository
needs to have a constructor that knows about projects which we're trying to avoid. - The factory has to explicitly declare the implementation type rather than an interface which makes it awkward to use in tests.
Given all that, I settled for a similar concept (injecting factories with a standard pattern for dependencies that need runtime info), but just hand make the factories instead of relying on Dagger injection.
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Do we need any specific form for testing your changes? If so, please attach one.
There's been a bunch of changes across the code base, but I think the main thing to check is that forms, instances and other pieces of data show up in the correct project.
Before submitting this PR, please make sure you have:
- [x] added or modified tests for any new or changed behavior
- [x] run
./gradlew connectedAndroidTest
(or./gradlew testLab
) and confirmed all checks still pass - [x] added a comment above any new strings describing it for translators
- [x] added any new strings with date formatting to
DateFormatsTest
- [x] verified that any code or assets from external sources are properly credited in comments and/or in the about file.
- [x] verified that any new UI elements use theme colors. UI Components Style guidelines