15.1 · MVC, MVVM, MVP, VIPER, RIBs, TCA and Clean, and unidirectional data flow
Every architecture answers the same few questions: where does state live, who is allowed to change it, and how do you test it. The names differ; the trade-offs mostly do not.
Mental model. Architecture is where you draw the lines. A good line makes one thing easy to test and one kind of change cheap; each extra line costs code and indirection.
Choosing a pattern
The family of patterns and their honest costs.
- How do MVC, MVVM, MVP, VIPER, RIBs and Clean compare, and which would you choose?
All of them separate what to show from how to show it, and differ in how many layers they add. MVC (Apple’s original) has a model, a view and a controller that…
One-way state
Unidirectional data flow and reducers.
- What is unidirectional data flow, and how does a reducer make state changes predictable and testable?
Unidirectional data flow means state changes travel in one loop: the view renders from a single state; user input and system events become actions (plain…
More in Architecture & API design
- 15.2 · Coordinators, routers and dependency injection
- 15.3 · Feature modules and boundaries, and strangling a legacy codebase
- 15.4 · throws, Result, typed throws and mapping errors at boundaries
- 15.5 · Designing a Swift API: naming, ownership, documentation and evolution
- 15.6 · SOLID without dogma, and building a platform for many apps
- 15.7 · Effects and cancellation, modelling state, composing reducers
- 15.8 · Closure-based clients, dependency lifetimes, generic repositories and building the graph lazily
- 15.9 · Binary breaks from innocent changes, and what an import exposes
- 15.10 · Types that prevent misuse, error types for libraries, one-shot values and when to trap