medic / cht-android

A native Android container for Community Health Toolkit (CHT) applications
GNU Affero General Public License v3.0
25 stars 50 forks source link

Integrate Dependency Injection Framework #264

Open jkuester opened 2 years ago

jkuester commented 2 years ago

Describe the issue For larger Java projects it can be very helpful to emphasize composition over simple inheritance when building out the class structures and hierarchy. Composition allows for proper code separation and reusability making things easier to understand and to unit test.

The big downside of Composition (IMHO) is that you end up needing to be able to pass around a bunch of different classes that you use when "composing" your logic. This is where dependency injection frameworks become very useful because they can abstract away this overhead and allow developers to focus on the just the flow of the activity data they care about.

Describe the improvement you'd like As our Java code-base here continues to grow and especially as we try to improve the coverage of the unit test cases, I think we should consider implementing a dependency injection framework such as Hilt.

jkuester commented 2 years ago

Also worth noting that this is the same concept as the Angular dependency injection that we are already using in cht-core...