VIPER (View-Interactor-Presenter-Entity-Router)
Clean Architecture for iOS.
“Separate the logic into five distinct layers.”
Extreme separation of concerns.
graph LR
V[View] <--> P[Presenter]
P <--> I[Interactor]
I <--> E[Entity]
P --> R[Router]
When to use
- Large iOS Apps: To prevent “Massive View Controller”.
- Enterprise Mobile: When testability is paramount.
Explanation
- View: Displays what the Presenter tells it to.
- Interactor: Contains business logic used to manipulate data (Entities).
- Presenter: Contains view logic for preparing content for display.
- Entity: Basic model objects used by the Interactor.
- Router: Handles navigation logic.
Pros and Cons
| Pros | Cons |
|---|---|
Code example
Typescript (Conceptual)