antoniolg / androidmvp

MVP Android Example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Where to reach domain layer from MVP

mfrachet opened this issue · comments

I'm trying to understand this pattern, and it seems clearer and clearer. Im a javascript developer, and React Native made me want to learn more about native android dev.

I've got the point that MVP resides in the pres' layer. I've got the point that we also reach backend data thanks to interactors and getting some DTOs (aka model in our cases).

I use to work with remote domain layer, using REST APIs entrypoints. But sometime, I've to deal with client side logic for offline treats or state mutations, some stuff like that.

I know that I shouldn't put this kind of computation inside of the presentation layer, and I was thinking of "deduping" (not really, but using a simplified version of my remote domain) in another module my business domain.

But the problem still exists, I have now two modules :

  • my pres layer with MVP
  • my domain layer, pure Java classes, no Android sdk classes

But I don't know where to connect both of these to create a scaling architecture. Like, where should I call my domain services ? In interactor ? In presenter ?

I m a bit confused for this part ^^'

@mfrachet I think you can call your domain services in interactor!Beause,I think put things about data to write them in interactor.

Yup, as @android-shiyan mentioned, the interactor usually receives the objects from the domain it needs to implement the action. It normally receives interfaces, so that it doesn't need to know the exact implementation.

This gets a little out of the purpose of this example (and article), but if you want to know more, you can check any of the many clean architecture implementations out there. You can probably start here: https://fernandocejas.com/2014/09/03/architecting-android-the-clean-way/

Looks like you have MVP pretty clear, so it's time to go to the next step 😉