I'm wondering if it is better to have a Module
per Activity
than a Module
per Fragment
? In one of my projects, I have an architecture to have a Module
per Fragment
because I use Activity
just to hold and swap Fragments
and nothing more. I only create Presenters
and Interactors
when I need them, i.e. when Fragment.onCreate()
is being called.
But I can see guys are creating Module
per Activity
in their examples. While the idea to have an independent Module
for Activity
sounds perfectly reasonable as for me from a modularity perspective, but I still believe creating and keeping all objects (Presenters
, Interactors
) before you actually need them is not a best idea. You can't also release resources when you don't need them, which you could easily do for Module
per Fragment
when you just release a scoped graph
in Fragment.onDestroy()
event.