Employing the MVI Pattern for your Android Application
Posted By : Daljeet Singh | 31-Oct-2018
Code Architecture is the way you organize and design the code for your application
The need for an architecture pattern
Architecting is especially important as your application code undergoes a lot of changes over a period of time, and these changes can leave your code in a pool of mess if the code is not
- Testability: Unit testing various parts of your code gets pretty tedious. Also using a Dependency Injection library like Dagger2 to reduce code coupling becomes virtually impossible.
- Maintenance: Code maintenance and addition/removal of functionalities become quite cumbersome.An increase in the time required to debug and resolve issues arising out of the code.
Because of the aforementioned issues, it becomes essential that we adhere to a coding architecture while writing code for our application. Some of the popularly used patterns for architecting android code are MVC(Model-View-Controller), MVP(Model-View-Presenter), MVVM(Model-View-ViewModel) and
The
While the
Intent : An Intent describes the intention of the user while interacting with the app.The Intent receives the input from the user in the form of UI events(e.g button clicks,field inputs) and translates it before delivering it to the Model in a manner that can be processed and understood by the Model.Model : The Model inMVI is immutable and responds to the Intent events.Each Model represents a state inside the app and a new instance of the model is created for every change of state triggered by the Intent events.View : The View represents the actual UI of the app.It observes the Model and propagates any changes in the state of the Model to the UI.
The
If you want to start out with your first project using the
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Daljeet Singh
Daljeet has experience developing android applications across a range of domains such as Cryptocurrency, Travel & Hotel Booking, Video Streaming and e-commerce. In his free time, he can be found playing/watching a game of football or reading up on either