VIPER architecture—Basic concepts

A fast explanation of each module:

  1. V(View/ViewController) —layer for handling user interactions, creating layout.
  2. P(Presenter) — layer for converting and preparing results of business logic to display on V layer.
  3. I(Interactor) — layer for fetching data from Network services, cache. Main business logic layer.
  4. R(Router) — layer for the logic of navigation between other VIPER modules.
  5. E(Entity) — E(Entity) — Models (local or domain), actual data.

Protocols part in VIPER — the main part

Wrong connections between modules

Pros of VIPER:

  1. Each module has strong responsibilities. It’s easy to change one module without changing another. (single responsibility principle).
  2. It’s easy to develop parts with a few developers. (If protocols created — that you can create the view which will communicate with presenter abstract class and another developer can create presenter for working with abstract view class.
  3. Testability (You can simply create a mock interactor class with confirmed protocol and it is easy to replace real interactor on mock interactor in test mode).
  4. High Maintenance. It is easy to maintain because you know what and where it should be. (View creation in view, text formating in the presenter, data fetching in interactor, navigation between modules in the router.
  5. Nice for Test Driven Development (TDD).

Cons of VIPER:

  1. For VIPER you need to create tons of boilerplate code. Even for the simple screen, you need to create at least 5 protocols and 5 classes for codebase consistency.
  2. It takes a lot of time. (You need to separate one screen on abstractions and 5 modules).
  3. You need a good understanding of ARC. because all modules have references on each other and you need to define which references must be weak.
  4. The bad pattern for always changing business goals and technical specifications. (You need to change a lot of protocols and classes in these conditions).

Conclusions:

--

--

--

iOS Software Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Delegate and protocol in swift

Position, Move and Stretch a UIView with contentMode

Adding Statsig to iOS

Controlling UIHostingController with SwiftUI View

Bézier Path and Curves Using Core Graphics

iOS and Android Developments are Converging Over the Years

Top iOS and Swift Developer Interview Questions for 2022

Using Type-Safe Identifiers in Swift

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Almost Engineer

Almost Engineer

iOS Software Developer

More from Medium

Swift UserDefaults Set Custom Object Value

Introduction to concurrency in iOS

Continuous Delivery of iOS applications using Fastlane

iOS : Automated Build Distribution — FastLane & Firebase & Jenkins — Part 1