Today I learned a new ios development architecture pattern called VIPER.

The general MVC development pattern

  • Problems arising
    • The View layer executes all the business code
    • The View layer is not separated from the Model
    • Controller is too heavy
    • Poor reuse value of code

VIPER

  • Meaning:
    • Views, Interactors, presenters, Entities, and Routing
    • View: UI display
    • Interactionators – includes business logic about data and network requests, such as creating an entity (data), or fetching some data from a server.
    • Presentator — contains business logic at the UI level and method calls at the interaction level.
    • Entities – Generic data objects that are not part of the data access hierarchy because data access is the responsibility of the interactor.
    • Router – Used to connect VIPER modules.
    • Architecture diagram

– Related information

Segmentfault.com/a/119000000… Segmentfault.com/a/119000000…

  • Our plan
    • DataTool: Data provider -> similar interactor
    • The model entity
    • view
    • Presener is responsible for presenting the Model on the View and covering the business logic at the UI level
    • The controller takes care of the data, gives the presenter the model to present to the view, and handles the unified scheduling of events for the view and manages the life cycle
  • In actual combat
    1. Ensure the independence of data-related business logic
    2. Keep views independent
      • 2.1 Remove business logic
      • 2.2 Elimination model