This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## 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.”* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let thread = Thread { | |
| print(Thread.callStackSymbols) | |
| } | |
| thread.start() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let thread = Thread { | |
| print(Thread.callStackSymbols) | |
| } | |
| thread.start() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let thread = Thread { | |
| print("NSThread starting...") | |
| Thread.exit() // exit thread internally | |
| print("Will never be printed") | |
| } | |
| thread.start() | |
| thread.cancel() // cancel thread externally |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Thread { | |
| Thread.current.threadDictionary["name"] = "Alice" | |
| print(Thread.current.threadDictionary["name"]!) // Alice | |
| Thread.current.threadDictionary["name"] = "Bob" | |
| print(Thread.current.threadDictionary["name"]!) // Bob | |
| }.start() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Task { @MainActor in | |
| print("Task scheduled on main actor") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Task.detached { | |
| print("Running on global actor") | |
| await MainActor.run { | |
| print("Switched to main actor") | |
| } | |
| } |
NewerOlder