iOS System Design
There is lots of material out there for system-design interview prep for backend roles. But mobile and iOS specifically is, well, more specific. This module focuses on (a) iOS and (b) on a system-design interview in particular.
Emerging Architectures
Traditional
The traditional iOS design is with UIKit, the delegation pattern and NotificationCenter, and singletons. The coordination pattern and presenters are popular.
New and emerging technologies
Emerging technologies are SwiftUI, Combine, and TCA. TCA, which is a Swift framework that implements the redux pattern on iOS (unidirectional flow, reducers+stores+views and all) is definitely an emergent pattern. Combine and SwiftUI are less new, but also fairly new. Combine seems mature at this point, whereas SwiftUI is still evolving.
which one to choose
It is good to know these emerging technologies and architectures, but if you have mostly (or only) shipped apps to production so far using traditional iOS design, then for the purposes of a system-design interview perhaps better to stick with what you know and know you can ship. Outside an interview context, when there is more time, I might in fact research and evaluate a new technology, but I am not sure I would do that on the spot when I only have twenty minutes to sketch out a complete solution. That said, SwiftUI and Combine might in fact be what you have been shipping with the last few years; if so, go for it.
psychology and, also, what’s the point?
How you would go about designing a system and how you would go about passing a system-design interview might well be two different questions. Psychologically, the two are bound to feel differently. On this page I focus on the genre of the system-design interview in the context of iOS.
A system-design interview, I gather, is meant to be a simulation of how you would actually work with real coworkers (e.g. with Product and Design) and with your engineering team to brainstorm a solution. Perhaps imagine that you are a consultant giving a 20-minute consultation to someone and that you are the expert (rather than being in the mindset that you are getting quizzed and the other person knows the answer which you are trying to guess).
Sample questions
Three sample questions
Design an app that shows whether your friends are online. The list should be sorted by last seen, with those who are currently online shown at the top. Pay attention to edge cases, such as going into a tunnel and losing connectivity (but please do not look at your phone if you are the driver).
Design the Uber Eats/Spotify/Airbnb/etc. iOS app.
Design the “disappearing messages” feature of a chat app.
The first question is interesting because it might make you think of paging and streaming rather than a simple request-response REST API. The second question is broad. The third question much more zoomed in on a particular feature.
answer in three steps
A system-design interview in three steps
Step 1. Don’t jump into solutioning. Instead, first, interview the interviewer to understand and gather requirements. Whatever the interview tells you will likely be underspecified. Write down the requirements.
Step 2. Then propose a solution by describing a high-level overview: e.g. networking, persistence, UI and view controllers (or not, e.g. wth SwiftUI), singleton for this or that?
Step 3. Then give the interviewer room to ask for a deep dive into one of these components. Because of this, it is important in Step 2 to stick with technologies with which you are comfortable; using a technology you have actually used in production might be better.
state machines and listening to the interviewer
It is important to understand the wishes the interviewer expresses. For example, if the interviewer says that s/he is curious about managing the lifecycle of the application, then it might be a good idea to write down, on the shared doc, “managing the lifecycle of the app” and address state transitions. For example, see this Apple doc.
Note that a state-transition diagram for this would probably look pretty different from the system diagrams below.
sample videos
two sample videos plus an overview
Here are some videos by Andrey Tech on this topic: first video (overview), second video (example 1), and third video (example 2).
Screenshots of diagrams from the above videos:
buyer beware
do not purchase Leetcode for this
Do not purchase Leetcode’s “system design interview” module. Leetcode is selling it for 75 bucks, but, at the time of my writing this, it is literally just a collection of these youtube videos, which were not recorded by Leetcode. It is not a collection similar to those videos, but is those videos. Also, note that those are about backend and not mobile architecture.