I’ve been working on my first (and very simple) Android application. I’ve been using a Model View Presenter approach and wondering if this is a typical pattern used by Android developers.
The main Activity is acting as the view and I pass it into the Presenter so both are aware of each other as illustrated below. The Presenter itself implements an IObserver interface that watches for state changes in the model, by having the model call IObserver.update. The Presenter then queries the Model’s state.
The Model’s job is to manage it’s own state and that of the ViewModels it returns, which are then bound to the Activity by the Presenter.
It seems to working quite well for me and avoids all the approaches I see online wherein people put business logic into the Activity itself.
Thoughts?
From what I understand MVP is a valid pattern, it just varies in the implementation details. Did you check out the Android Architecture examples yet?
https://github.com/googlesamples/android-architecture
I just found out about them recently and am using them to brush up on some newer frameworks that I’m not using at work yet.