0EFDQKW84D

Not long ago, the Android community started adopting patterns like MVP, MVVM, etc. There are a lot of teams out there who spent days, weeks, months and even years refactoring their legacy apps to adopt these patterns. They are all pretty happy with the state their current code is in. Recently, we all started hearing this other term called MVI or Model View Intent and we have seen a lot of talks and blog posts about this pattern.

Whenever we see a talk on MVI, there are a few things which are not quite clear on the first go. There’s a lot going on with the implementation and things like Action, Result, Processor, Reducer complex reactive chains, etc. This could easily overwhelm anybody without knowing the reason: “Why they would want to further complicate their life any more than it actually is?”

On top of that, we are already pretty happy with the way things are with our current codebase. It’s been quite some time since we adopted MVP and let’s not forget the cost of bringing the whole team to learn and implement it. Now that we have another pattern, should we trash all these efforts and start from scratch and go through the same process all over again?

I say No, we need not build everything from scratch.

 

MODEL VIEW INTENT

Model is a term which is common to various patterns like MVC: Model View Controller, MVP: Model View Presenter, MVVM: Model View ViewModel.

I have always been unsure of this Model term, what exactly it applies to, so I have an interpretation of my own, which goes something like this: Model in MVP or MVVM is everything other than the View and Presenter (or ViewModel). This can also be called the data/logic layer.

Some people like to say that Model is state. If we represent everything going on a screen as a container of states, like isLoading, isChecked, it becomes our model. This definition of Model is more closely related to the MVI’s Model.

There are four basic elements in this State View Intention pattern. Can you take a guess? If you said those are State, View, Intention, and User then you are a winner!

The addition of User in the pattern itself is what makes it different from other patterns.

Liked the article?
Subscribe to our newsletter.

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.