Simplifying Android Architectures for Developers — MVC, MVP, MVVM, Clean, MVI — part 6: VIPER

André Figas
3 min readSep 22, 2022

--

VIPER

Theory

Finally, this is an Architecture that does not have exactly 3 layers.

I will use MVP to make comparisons here because it is a similar architecture.

viper diagram

View

This layer is responsible to update UI and receiving UI triggers like a user click, or some life cycle event, and requesting information from the Presenter Layer.

Difference: Here we will remove the responsibility of navigating to other pages.

Entity

The entity contains Databases, business rules, and access to external resources. (Basically, they renamed the model layer)

Presenter

This layer is responsible to connect the data layer, requesting information, and returning information to the view layer.

Difference: We removed the responsibility to handle the states of our requests, now this layer is really just a connector.

Interactor

This layer receives requests from the presenter and returns information to that layer, and handles the state of that call.

Route

As I told you, the responsibility of navigation was removed from the view layer. So that was moved to this layer.

Practice

First of all, since this architecture is too specific about the connector layer Presenter, I won't replace it with other connector layers.

About the entity layer, I did not think it necessary to rename and move our model layer. Conceptually, that will behave like this architecture describe as the Entity layer.

And finally, before letting you see the code, I had to make a subtle change to our workflow. Before, after you submit a User, It sent you a toast message. Now It will redirect you to a success page for demonstrating how the Route Layer works.

New feature

As I told, I had to created a new activity to receive the success message after submit action. I will show only the activity but I had to create a new manifest entry and layout .xml too.

Route

Interactor

This is really similar to the Presenter conpect from MVP Architecture, but here, we are receiving callback as paramenter and frowording it for the model layer. The proposal here is handle the state of our calls.

Presenter

View

If you are following this sequence of artichles, maybe you are expecting I make the merge between this architecure and other compatible architecture. So, let's do it:

VIPER + Clean

VIPER + MVI

VIPER + MVI + Clean

--

--