SwiftPumpkin

1 of 20 · UI patterns

MVC

MVC (Model–View–Controller) is an architectural pattern that separates an application's data, presentation, and coordination logic. It is the traditional architectural pattern in UIKit-based iOS development.

How it's wired

UpdatesDataEventsRendersControllerCoordinates everythingModelData + business logicViewUI + rendering
calls or tellsreports backIn UIKit MVC, the Model and View don't communicate directly.
  • Views send actions to the controller (target-action, delegate).
  • The model notifies the controller when it changes, and the controller updates the views. Views and models never talk directly.
PartOwnsLooks like
ModelData, state, domain logicStructs, plus stores or services that load and save them
ViewDisplay information and capture interactionsUIView, UILabel, UIButton
ControllerHandle events, coordinate model and viewUIViewController

A thin controller is fine

Nothing to extract: data comes in and is rendered.

AboutViewController

An AboutViewModel, a protocol and mocks would add indirection, not value.

final class AboutViewController: UIViewController {
  @IBOutlet private var versionLabel: UILabel!

  override func viewDidLoad() {
    super.viewDidLoad()
    title = "About"
    versionLabel.text =
      Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
  }
}

MVC is reasonable when the controller is genuinely thin.

Why MVC becomes problematic at scale

  • MVC is the starting pattern. Every other UI pattern here is a refinement of it: MVVM pulls presentation out of the controller, a router pulls out navigation, and VIPER splits business orchestration from presentation.
  • Massive View Controller symptoms: 1,500-line controllers, logic tied to viewDidLoad and viewWillAppear timing, code untestable without UIKit, and constant merge conflicts.
  • UIKit already gives the controller a full job: lifecycle, its view hierarchy, layout, user input, and presenting other screens.
  • As a feature grows, more piles on: networking, persistence, business rules, formatting, loading and error states, navigation decisions, analytics.
  • This leads to tightly coupled dependencies, slow code reviews, difficult unit testing, poor reusability and expensive migrations.
  • It also makes AI edits less correct and more expensive. To change one thing, an agent has to read the whole class, and a change to one concern easily breaks another. The more complex the feature, the worse it gets.
  • However, Massive View Controller is not an inherent requirement of MVC. It's a consequence of poor responsibility boundaries.
  • Good dependency boundaries (protocol-oriented dependencies, facades, dependency injection, feature modularization) keep an MVC codebase healthier, but they don't stop responsibilities piling into the controller. That's what MVVM and routers are for.

My decision rule

Thin static screens (About, Licenses, simple Settings)MVC: no presentation logic worth extracting.
Interactive screens with async state or validation (feeds, forms, search, detail views)MVVM with a Router: keeps state and formatting testable without UIKit.
Complex flows where business rules and UI evolve independently (checkout, pricing, contact picker)MVVM + Interactor, or VIPER for that flow.
Multi-team hierarchical business trees (ride-hailing states, logged-out vs logged-in graphs)Consider RIBs.

Step by step

Moving a team off plain MVC

  1. Find the painUse regression history, testing friction, dependency graphs and upcoming product work.
  2. Set principlesState ownership, dependency direction, lifecycle and module responsibilities, before choosing a pattern.
  3. PilotOne representative feature: complex enough to prove the approach, contained enough to limit risk.
  4. Migrate graduallyMVC and the new structure coexist. Extract services, inject dependencies, move presentation logic where it pays.
  5. Pave the roadReference implementations, templates, test utilities and clear guidelines, so nobody has to be an architecture expert.
  6. MeasureRegression rate, testability, onboarding friction, implementation effort and build time.

Compared

What each technique addresses

Architectural problem it addresses
MVCCoupling between data and UI
MVVMMassive ViewControllers
MVVM + RouterCoupling between feature logic and navigation
VIPERMassive ViewModels and mixed presentation/business logic
Protocol-oriented programmingCoupling to concrete implementations
Dependency injectionCoupling to dependency construction
Feature modularizationCoupling across feature boundaries
FacadesLeakage of subsystem complexity

Where MVC is enough

Why
Static About or legal screenNo meaningful presentation state
Simple image previewMostly rendering and gestures
Debug or internal toolLow complexity and maintenance expectations
Throwaway proof of conceptOptimizing for learning, not longevity
Wrapper around a system componentUIKit already does most of the work
Static informational sheetData is passed in and rendered directly

When to move a team off plain MVC

Architectural response
Business logic depends on UIKit or the view lifecycleExtract headless services and domain logic
Presentation logic has complex state transitionsIntroduce MVVM or a dedicated state machine
Testing business behavior requires loading view controllersSeparate the logic and inject dependencies
Navigation is tightly coupled across screensIntroduce coordinators or routers
Several engineers or teams keep modifying the same componentsEstablish feature and module boundaries
Features have independent lifecycles or dependency scopesIntroduce feature-scoped architecture
Changes keep causing unintended regressionsExplicit state ownership, contracts and testable boundaries
The roadmap brings substantial complexityAdd the right boundaries before coupling accumulates

Untangling a massive view controller

Why this order
First: cover critical user journeys with testsMap async work, lifecycle dependencies and shared mutable state before moving anything
1. Pure computation, validation and transformationLow risk. Easy to characterize and unit test without UIKit
2. Networking, persistence and other side effectsEstablishes dependency boundaries and makes tests deterministic
3. Independent UI componentsCohesive views with clear inputs and callbacks; screen behavior stays the same
4. Presentation logic and state transitionsWith dependencies isolated, a testable ViewModel or presenter where warranted
5. Navigation and feature orchestrationA coordinator, if navigation complexity or reuse justifies it
The order is a defaultMain-thread stalls from the database: isolate persistence first. Five engineers in one file: split by feature first. Inconsistent UI from async callbacks: fix state ownership first. Stable, rarely touched: extract as features land

Expert notes

  • UI architecture is not just about organizing UI code. It's about controlling state, responsibility, coupling and the cost of change.
  • In UIKit this matters because UIViewController already owns lifecycle, view hierarchy, layout and interaction handling. Adding presentation logic, business orchestration and navigation makes it an architectural bottleneck.
  • These techniques solve different dimensions of complexity. You can't compensate for poor UI architecture with protocols and dependency injection: a 3,000-line view controller with perfectly injected dependencies is still a poorly structured view controller.
  • Why: injection makes its dependencies swappable, but the class still does every job. It still changes for every reason, and its logic still only runs inside UIKit.
  • Use MVVM from day one, even on your own, for messaging, social feeds, sign-in and onboarding, search, checkout, offline support, or any screen fed by several async sources. Their state is complex and keeps changing.
  • A few simple screens can stay MVC inside an MVVM app, as long as they get their dependencies and navigate the same way as every other screen. Just don't make MVC the default for a large UIKit app.
  • Team size is a multiplier, not the deciding factor. Two people building encrypted messaging may need stronger boundaries than twenty people maintaining simple CRUD screens.
  • Don't add a ViewModel that only forwards calls between a view controller and a service. That's indirection without a real separation of responsibilities.
  • Standardize boundaries more than patterns. One app can have MVC screens, MVVM features and state machines for complex flows. What must stay consistent is where business logic lives, who owns state, how dependencies are resolved and how behavior is tested.
  • MVVM is cheap to adopt: no binding framework, just a class the view reads from. MVC costs even less, which is why it only wins on screens with no logic to move.

Check yourself

Answer out loud before you reveal. Recall is what makes it stick.

30-second answer

Explain MVC in 30 seconds.

SwiftAsked directly

What is "Massive View Controller" actually a symptom of?

System designAsked indirectly

Two tabs show the same notes. You edit in one and the other shows stale data. What's wrong with the design?

iOS codingAsked indirectly

You inherit a 1,500-line view controller. What do you extract first, and why in that order?

System designAsked indirectly

When would you move a team off plain MVC, and how?

Read it in the app's source

Done with MVC? Mark it complete. Nailing its cards builds this pumpkin, row by row.