Explain the Coordinator pattern and the navigation problem it solves in MVC

This tests if you see view controllers bloat from absorbing navigation flow. A good answer names 3 problems (delegate bloat, massive view controllers, embedded routing) and says coordinators own creation and routing.
What's really being asked
The interviewer wants to know if you understand the architectural pressure that traditional MVC puts on view controllers in UIKit. Specifically they are looking for recognition that view controllers naturally accumulate responsibilities that have nothing to do with views or user input and that navigation flow is one of the most damaging to reuse and testing. The question also checks whether you can articulate the coordinator pattern as a concrete solution rather than a vague buzzword.
The full answer
First name the three problems Khanlou identifies. One the app delegate becomes a dumping ground for root view controller configuration. Two view controllers bloat with unrelated duties like model mutation data fetching layout and navigation. Three navigation flow gets embedded inside view controller methods such as tableView didSelectRowAtIndexPath directly instantiating and pushing a detail view controller. Second define a coordinator as an object that sits above view controllers and owns the flow of the application. It creates view controllers injects dependencies and decides when to present or push them. Third explain the benefit view controllers become isolated units that know nothing about their presentation context making them reusable and testable. Fourth mention that coordinators can be nested or have children allowing complex flows to be broken into manageable pieces.
The mistakes people make
Saying coordinators are just for deep linking or URL routing misses the core purpose of removing navigation from view controllers. Claiming that view controllers should still push each other but coordinators handle the back button is equally wrong. Another red flag is describing the pattern as overengineering for small apps without acknowledging that the problem is MVC structural tendency to create massive view controllers. Interviewers also frown on answers that conflate coordinators with view models or routers from VIPER without explaining the distinction.
What usually comes next
How do you pass data back from a view controller to a coordinator. How do you handle deeplinking or state restoration with coordinators. What happens to the coordinator lifecycle when a user dismisses a modal flow. How do you avoid retain cycles between coordinators and view controllers. Can you mix coordinators with SwiftUI or UIKit programmatic layout.
A concrete example
Imagine a login flow. A LoginCoordinator is initialized with a navigation controller. It creates a LoginViewController sets itself as the delegate or callback target and pushes the login screen. When the user taps sign up the LoginCoordinator creates a SignUpViewController and pushes it. When authentication succeeds the LoginCoordinator tells its parent AppCoordinator that the user is logged in and the AppCoordinator swaps the root flow for a MainTabCoordinator. The LoginViewController never touches the navigation controller directly it only notifies its delegate that a button was tapped.
Interview question
Which statement accurately describes the Coordinator pattern's primary purpose in an MVC architecture?
- a.It replaces view models in VIPER by handling all business logic centrally
- b.It allows view controllers to push each other while coordinators manage the back button
- c.It moves navigation flow and view controller creation out of view controllers into dedicated objectsCorrect
- d.It provides deep linking and URL routing for the entire application
Why? this is the answer
The coordinator pattern moves navigation flow and view controller creation out of view controllers into dedicated coordinator objects, isolating view controllers for reuse and testing. Claiming that view controllers should still push each other while coordinators only manage the back button is incorrect because navigation logic must be fully extracted, not partially shared.
Just read this? Test yourself on what you have been reading.
Read the original → khanlou.com
- #ios
- #swift
- #coordinator-pattern
- #mvc
- #architecture
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on ios — each one lists the topics its interview covers.
See open roles