View Interactor Presenter Entity Router (VIPER)
The View Interactor Presenter Entity Router (VIPER) is an architecture pattern that separates objects into five distinct types mainly made up of View, Interactor, Presenter, Entity and Router.
VIPER divides the logical structure into distinct layer of responsiblities which then isolate the app’s dependencies. With that you, there are multiple components which play different role here:
- View delegate user interaction to Presenter.
- Interactor mediates between the Presenter and data where it takes instruction from the Presenter.
- Entity aka as Model holds the application data.
- Presenter mediates between View and Interactor and use Router to move to different screens.
- Router handles navigation between screen.
VIPER focuses heavily on Presenter where its sole purpose is the View and user action whereas, Interactor focuses on manipulating the data.
When should you use it?
VIPER becomes the preference for most big projects. However, it could be really difficult to understand for beginners due to the large number of components being used.