VIPeR

What is Viper in general?

Viper is the architectural pattern for development in the iOS environment. It’s especially interesting since it does not belong to any category MV(X). It was created in search of the best solution for iOS programming. It’s like Clean Architecture, but only for iOS development.

V.I.P.E.R — View, Interactor, Presenter, Entity and Router.

View – it’s an abstract interface, which is defined in Objective-C using the protocol.

Interactor –  it’s a simple Use Case in the application, which contains the business logic for managing objects (Entity), to perform a specific task. The task is performed in Interactor, regardless of any UI.

Presenter – contains business logic for managing the UI. It collects incoming data from user interaction. Thus, it can send requests to Interactor. Presenter gets Interactor results too, and convert the results to a state, which is the most effective for displaying on the View.

Entity – it’s are simple objects controlled by Interactor.

Router – responsible for the transitions between VIPER-modules.

If it’s just Viper – it’s just a normal MVC, where the controller is divided into two parts: interactor and present. View stayed in place, and the model renamed to entity. The router is deserves special attention, as others architectures don’t even mention this part in their abbreviations. But it is present in them and worth mentioning.

Advantages and disadvantages of Viper:

Advantages:

  • Increase the testability of the Presentation-layer applications.
  • Full independence of the modules from each other – this allows them to independently develop and re-use them in one application, as well as in several.
  • Transfer of the project to other developers, or the introduction of a new. This is much simpler, since the general approaches to architecture are predetermined.

Disadvantages:

  • A sharp increase in the number of classes in the project, this is a challenge when creating a new module.
  • Some of the principles don’t lie directly on UIKit and Apple’s approaches.
  • The lack of an open access set of specific recommendations, best practices and examples of complex applications.

Alt text

Our company is the ios mobile app development and has already worked with Viper. We have the mobile app on iTunes – Get Habit, which helps to form a habit for 21 days. Open source of this mobile application you can be found on GitHub.  Also, we have the templates – Viper-Swift, which any ios-developer can use for their projects, and corrections are always welcome.

For what we need the templates?

The creating the new module is one of the most vulnerable places in Viper. For creating the new module-displays you need:

  • Five new classes (Assembly, ViewController, Presenter, Interactor, Router);
  • Five new protocols  (ViewInput, ViewOutput, InteractorInput, InteractorOutput, RouterInput);
  • Five new tests (AssemblyTests, ViewControllerTests, PresenterTests, InteractorTests, RouterTests).

In addition, you need set all the necessary connections, add the realization of protocols, tune the dependency injection container. And in special cases are still many other actions. This complexity develops two main problems:

  • A great waste of time for simple mechanical work;
  • The probability of typos – increases. And as we know, it can greatly damage the logic of work.

On that, our developers were looking for a solution, how to simplify the creation of modules. As a result, they created the templates.

If you don’t know how to use the open source, our ios-developers will always be happy to help you with this. 

Предоставляет сравнительные обзоры ravenscards.com между непатентованными препаратами и их аналогами

Leave a Reply

Your email address will not be published. Required fields are marked *