I don’t know if you ever read the book rework, from the founders of basecamp, that’s what I’ve been doing: rework.
In the last posts I’ve been writing about the switch to programming in swift, and the setups for synchronizing data between macOS and iOS through CloudKit. Well, it’s still not finished, and I’ve started reworking my apps. Let me explain.
I’ve rewritten the iOS app in swift, and written a macOS version of the app. So far so good. This is all working fine on the local devices. I can also get data from CloudKit and sent data to CloudKit on both platforms, so that’s fine too. But covering all scenario’s to keep everything in synch, is more challenging than I thought.
You expect to be able to work with all your devices in an off-line mode. You may be on an air plain with your MacBook, or your iPad has no mobile connection, only WiFi… you expect that you can get all data magically synchronized and up-to-date once you get a connection. Your iPad may have not been on for several days, but you updated a lot of stuff on your iPhone…
Deciding how to manage changes you make in your local app, and tracking if the changes are uploaded successfully to CloudKit at first sight seems straightforward. But than you have to managed conflicting changes made on the same record (data) on different devices. So you start tracking changes and the moment that change was made, and compare it to what is in CloudKit… Before you know it you add state and date/time tracking to every field in your database… It’s a mess.
So you rethink what information is stored when, where, how, and what the logic is behind it. You write this out and think of all the possible use cases, to see what works for your app. You try to keep a good balance between complexity and functionality, keeping in mind that for the user, the behavior is normal and consistent… So that’s the challenge for the next weeks or so… reworking change logging and business logic…
Sounds easy enough. I’ll let you know.