Skip to content

Instantly share code, notes, and snippets.

@jacobsapps
jacobsapps / gist:6dd6fe3b0d793e54f0011a77d25cb2c5
Created November 19, 2025 14:43
News Feed System Design – Practice Transcript
## News Feed System Design – Practice Transcript
### 1. Problem & Scope
- **Interviewer:** *“Is this a standalone MVP or part of the main app? What infra are you leaning on?”*
**Candidate:** Integrating into the existing Meta app, using the shared GraphQL-over-HTTP stack with generated Swift models. Focus on iOS client, but define backend touchpoints as needed.
- **Interviewer:** *“Any scope constraints?”*
**Candidate:** Ads, posting flows, and heavy offline persistence are out for v1. Must plug into feature flags, analytics, and the experimentation framework.
### 2. Functional / Non-Functional Requirements
- **Interviewer:** *“List the requirements explicitly.”*
@jacobsapps
jacobsapps / gist:9f42a4e963736f28484e54f0eb71ceef
Created November 19, 2025 14:34
News Feed System Design Practice
## News Feed System Design Practice
**Candidate:** Clarifies that the feature integrates into the existing Meta app, asks about networking style (REST/gRPC/GraphQL) and the boundary between iOS and backend responsibilities.
**Interviewer:** Confirms integration, explains that the app uses GraphQL over HTTP with generated Swift models, and that the candidate can describe backend touchpoints as needed.
**Candidate:** States initial assumptions: no ads in v1, infinite scroll with paginated data, no on-device feed persistence yet, but feature flags/analytics hooks are required.
**Interviewer:** Accepts assumptions and requests an explicit list of functional and non-functional requirements.
**Candidate:** Defines requirements—feed supports text/image posts with like/comment/share, infinite scroll, pagination, 60 FPS target, skeleton loaders, aggressive prefetching, out-of-scope posting/ads/offline.
**Interviewer:** Approves scope and asks for architecture/data-flow details.
let thread = Thread {
print(Thread.callStackSymbols)
}
thread.start()
let thread = Thread {
print(Thread.callStackSymbols)
}
thread.start()
let task = Task {
print("Start task") // prints
try? await Task.sleep(for: .seconds(1))
print("Haven't checked cancellation yet") // prints
try Task.checkCancellation() // or, if Task.isCancelled { return }
print("End task") // does not print
}
task.cancel()
let thread = Thread {
print("NSThread starting...")
Thread.exit() // exit thread internally
print("Will never be printed")
}
thread.start()
thread.cancel() // cancel thread externally
enum User {
@TaskLocal static var name = "n/a"
}
Task {
print(User.name) // n/a
User.$name.withValue("Alice") {
print(User.name) // Alice
Task {
print(User.name) // Alice
Thread {
Thread.current.threadDictionary["name"] = "Alice"
print(Thread.current.threadDictionary["name"]!) // Alice
Thread.current.threadDictionary["name"] = "Bob"
print(Thread.current.threadDictionary["name"]!) // Bob
}.start()
Task { @MainActor in
print("Task scheduled on main actor")
}
Task.detached {
print("Running on global actor")
await MainActor.run {
print("Switched to main actor")
}
}