Technologies

VIPER

VIPER is an application design pattern with a distributed modular architecture. It's a popular alternative to MVC, MVP, and MVVM patterns that simplifies project work for large teams, makes it easy to conduct unit tests, and reuse code.


VIPER is used for iOS development, but Android has an analog of the pattern - Clean Architecture, which was used as the basis for this architecture.

How VIPER works
01
View

View is a module of the interface layer that displays the changes transmitted to Presenter and sends back information about user actions.

02
Interactor

The main business logic of the application that is not related to the interface. It receives data from the database, placed in a separate Model module, through the Entity layer.

03
Presenter

An intermediary module responsible for transferring data between View and Interactor. To ensure that information from the database is displayed correctly in the interface, it formats it by creating an appropriate instance of the class.

04
Entity

The storage of the object model accessed by Interactor. Contains only data objects without business logic.

05
Router

Navigational logic that describes how the actions caused by the user in the application will be performed.

In addition, applications with VIPER architecture store a modified Model layer - a database with network and local request managers that Interactor will access. These dependencies are not included in the general template and can be implemented in the classical way. In addition, developers can add other layers and shells to optimize the project for specific tasks, but the main parts of the application will still work according to the described template.

Why developers use VIPER
01
01
Separate modules and clean code

All software architectures are designed to simplify and streamline collaborative development. With Viper, which has more separate modules than classic patterns, these tasks are solved as efficiently as possible. In addition to the ability to involve more people, the code itself using this architecture will be cleaner, more structured and compact, and most importantly, reusable. This is due to the fact that each module has its own clear area of responsibility, not a blurred one, as in MVVM, and many classes for quickly changing any block.

02
02
Scalability

Viper's low-coupling, high-cohesion nature allows you to modify the functionality of the application at any time by placing it in a separate module, possibly without affecting other components of the application at all. And all this with a minimum number of merge conflicts.

03
03
Additional modules

The Router, which is responsible for navigation, allows you to reuse interface components and View as a whole without touching other modules, significantly saving development time. Entities reduces the load on the Model and makes the system faster and more stable.

04
04
Development based on testing

Viper is the ideal architecture for Test Driven Development (TDD). 99% of the entire program code can be covered by tests without significant time costs compared to using any other architecture. This is possible due to the fact that business logic and application interface are very loosely coupled in this way, and you can write a lot of automatic tests.

Conclusion

Your developers will know which design pattern is best for the project as soon as you tell them what your app needs to do. VIPER is one of the basic iOS app architectures that is best suited for large-scale projects. It requires more experience and skills from developers, but it makes it possible to modify the application at a minimum cost whenever necessary. In addition, VIPER makes it easy to automatically test literally every piece of code, which is equally good for projects of any size.