akai-org / akai-org/Mobile-learning-pokemons

DI Implementation

Aperta
#1 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
Kotlin
Stelle
0
Fork
1
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Although this is a working app, still some improvements can be done here. One of which is dependency injection. Take a look at MainActivity where we create viewModel and its dependencies by hand. Usually to avoid that we use Dependency Injection libraries such as Dagger-Hilt or Koin.
The benefits of DI pattern are:

- better code reusability
- better code readability
- we can test components and provide mock dependencies (we don't wanna use a real api or database for testing so we mock one)
- minimalizing vulnerability for changes - code is less dependent on its injected dependencies

If you'd like to learn more about dependency injection in android here are some useful links:

- https://en.wikipedia.org/wiki/Dependency_injection
- https://developer.android.com/training/dependency-injection/hilt-android
- https://insert-koin.io/
- https://www.youtube.com/watch?v=ZE2Jkvnk2Bs (hilt)
- https://www.youtube.com/watch?v=EathumJlWh8 (koin)
- https://medium.com/gradeup/dependency-injection-dagger-hilt-vs-koin-ab2f7f85e6c6

And the task is....
to implement dependency injection in our app - (personally I like hilt better than koin but it's up to you which library you choose, hilt dependencies are already included in the app gradle file as commented lines)
If you'd like to try and implement it - good luck and feel free to ask for help or any other extra materials.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.