← All topics/Architecture & design patterns

Architecture & design patterns interview questions

Scenario-style prompts with sample answer outlines. Focus is on how you would design and reason in real codebases.

  1. 01MVVM: where logic lives in UIKit vs SwiftUIYour team is standardizing on MVVM. How do you decide what belongs in the view controller or view vs the view model? What mistakes create 'fat' view models or leaked UIKit in the domain layer?
  2. 02Coordinators and navigation ownershipYou're hitting retain cycles and inconsistent back-stack behavior when view controllers push each other. How does a coordinator-style flow help, and what are the tradeoffs?
  3. 03Dependency injection: initializers, containers, and test seamsThe codebase uses a global ServiceLocator.shared singleton for networking and analytics. What problems does that cause, and how would you migrate toward something testable?
  4. 04Repositories, use cases, and data boundariesView models are calling URLSession directly and caching in static vars. How would you introduce a repository or use-case layer without over-engineering?
  5. 05Feature modules, SPM packages, and build graphsBuild times are growing and teams step on each other in one Xcode target. What modularization strategy would you propose, and what mistakes make modules worse?
  6. 06Single source of truth and duplicated stateUsers see different counts on the list and detail screens after an edit. Architecturally, how do you prevent multiple 'caches of truth' for the same entity?
  7. 07Refactoring a massive view controllerA 4,000-line view controller handles networking, analytics, and SwiftData. What incremental refactor plan would you present?
  8. 08Loading, empty, and error states across featuresEvery screen implements spinners and alerts differently, causing inconsistent UX and duplicate code. What architectural approach unifies this?