December 2018
Intermediate to advanced
414 pages
10h 19m
English
A fake object is a simplified version of a collaborator, with similar or partial functionalities, but implemented in a simpler way. Considering a version of TaskManager that stores the tasks locally, using a store object as a collaborator, whose implementation is unknown to the TaskManager, it might be implemented as file-persistent on file or database-persistent with CoreData.
TaskManager relies on the store to persist the tasks:
class TaskManager { private let store: TaskStore init(store: TaskStore) { self.store = store } func add(task: Task) { store.add(task: task) } var count: Int { return store.allTasks.count }}
TaskStore has the following interface:
protocol TaskStore { var allTasks: ...Read now
Unlock full access