-2

I am new in the MVVM architecture, and every documentations I found on internet use Dagger with the MVVM architecture. Dagger is style fuzzy for me and seems to me to be over-complicated to just create an android app. So my questions are simple:

  1. Why should/must I use dagger with MVVM architecture? And why Dagger comes not as often with MVP architecture than with MVVM architecture?
  2. Is it possible to develop an android app with MVVM architecture and without dagger?
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Moussa
  • 4,066
  • 7
  • 32
  • 49
  • MVVM is a pattern while Dagger is a library. Its upto you if you dont want to use Dagger. refer this link https://www.wintellect.com/model-view-viewmodel-mvvm-explained/ – Deepak kaku Mar 19 '19 at 19:00
  • """over-complicated to just create an android app.""" having implicit complications from not applying dependency injection isn't necessarily a better strategy. – EpicPandaForce Mar 19 '19 at 19:52

3 Answers3

1

You don't need Dagger in the MVVM architecture or the MVP architecture - Dagger is just a dependency injector library. You can use lazy loading in Kotlin now or Koin as a replacement for Dagger. There is no dependency on Dagger for the architecture patterns.

Ryan Godlonton-Shaw
  • 584
  • 1
  • 5
  • 18
1

I disagree with people who said that dagger is just library.

Dependency Injection : Is a concept and a way to code, and dagger make it more easy to take advantage of dependency injection with annotations.

Also the Sun-Flower project from google didn't use dagger while using MVVM pattern.

Ibrahim Ali
  • 1,237
  • 9
  • 20
1

Dependency injection is just an idea.

Dagger2 is a library which uses annotation processing to help with dependency injection boilerplate.

Even Jake Wharton says Dagger2 can be overkill for smaller apps.

It's absolutely possible to develop an MVVM app without a DI framework. Technically you don't need DI at all, but it does tend to make things easier - especially in regards to testing.

RBusarow
  • 644
  • 7
  • 12