Mobile TODO App: Implement a Persistent TODO List with Offline Sync on Android/iOS
Interview Experience
Problem
Build a mobile TODO application with the following requirements: add, complete, and delete tasks; persist state locally so data survives app restarts; sync with a REST backend when connectivity is restored.
swift
// iOS (Swift)
protocol TaskRepository {
func fetchAll() -> [Task]
func add(title: String) -> Task
func complete(id: UUID)
func delete(id: UUID)
func syncWithRemote(baseURL: URL, completion: @escaping (Result<Void, Error>) -> Void)
}
struct Task {
let id: UUID
var title: String
var isCompleted: Bool
var updatedAt: Date
}
Edge case: A task is deleted locally while offline, then the server sends it back during sync. Define the conflict resolution strategy.
Follow-ups
- How do you handle the case where two devices edit the same task offline simultaneously?
- Should sync be optimistic or pessimistic? Justify your choice.
- How would you implement a soft-delete so deleted tasks can be recovered within 30 days?
- What schema migration strategy would you use if Task gains a new required field?
Full Details
Problem
Build a mobile TODO application with the following requirements: add, complete, and delete tasks; persist state locally so data survives app restarts; sync with a REST backend when connectivity is restored.
swift
// iOS (Swift)
protocol TaskRepository {
func fetchAll() -> [Task]
func add(title: String) -> Task
func complete(id: UUID)
func delete(id: UUID)
func syncWithRemote(baseURL: URL, completion: @escaping (Result<Void, Error>) -> Void)
}
struct Task {
let id: UUID
var title: String
var isCompleted: Bool
var updatedAt: Date
}
Edge case: A task is deleted locally while offline, then the server sends it back during sync. Define the conflict resolution strategy.
Follow-ups
- How do you handle the case where two devices edit the same task offline simultaneously?
- Should sync be optimistic or pessimistic? Justify your choice.
- How would you implement a soft-delete so deleted tasks can be recovered within 30 days?
- What schema migration strategy would you use if Task gains a new required field?
About This Question
This is a candidate experience report from a notion interview during the onsite round.
It covers the following topics: Strings, Ios, Android, Coding, Onsite .