18 July 2021

Weekly Project Update 2: Nothing’s Finished

I didn’t spend a lot of time working on side projects this week. News of the Covid-19 outbreak in Melbourne was weighing on my mind. I guess at this stage there’s no real need to work on them: this is currently still a hobby, and it’s not like there’s a deadline associated with them.

But I have to acknowledge that there’s a downside to thinking this way, particularly if I want to make this more than just a way to kill time. After all, in order to share something with others, it has to be in a state that could be loosely defined as finished”; and at the moment, none of the projects I’m working on is really in this state. This is a bit of a problem of mine: it’s always more fun to start new projects than it is to follow through and polish them up, particularly when building something for yourself.

I’m not quite sure how I would be able to work through it though. Maybe seeing someone post about a problem that I’m trying to solve myself would motivate me to actually get something to a shippable state. Maybe applying rules like no new projects until I finish the one’s I’m working on new” is the way to go, although past experience with trying this has not been super successful. Maybe writing these reports would help.

Anyway, on to this weeks update.

Day One Sync

Despite doing a little this week, I did manage to get some work done on this project, mostly on the backend” (i.e. not the user interface). In the last update, I mentioned that I upgraded my OS to Big Sur in an attempt to get a newer version of Xcode with the hope of adding SwiftSoup as a Swift package. Well, I tried that, and I was still seeing the same error. I didn’t want to waste any more time on it so I decided to move the dependencies to CocoPods, which worked without a hitch. It’s a shame that I can’t use the official” facilities that Apple is building, but I guess CocoPods has been around for much longer, and will probably have better community support anyway.

The other major work done this week was getting Core Data working. This will be used to store the configuration options for the feeds that will be polled. The entities were already been defined but before this week I was unable to get anything written to the store. I was having trouble in how I could deal with the managed objects in the view controllers outside a persistence context.

I think I’ve found a solution to this, and although it works, I already feel that it’s the wrong one. It’s one inspired from a pattern I used when working with, of all this, enterprise Java apps. Basically, I have two classes for each entity: one which is managed by the persistent context, and another which is just a plain Swift class acting as a DTO. While there are strict rules regarding how to work with entities, the DTOs themselves can be worked with like any other type: there’s no magic to them at all. The fields of a DTO can be copied to an entity, and visa-versa, making it easy to separate concern: I can keep the entities in a repository class that has methods that take and return DTOs.

I’m probably making this more complicated than it needs to be, most likely because my knowledge of Core Data works is relatively limited. It’s also probably my experience with working with other ORMs, and the associated magic” that comes from that. Magic in your application is a double-edge sword: it might make it easy to develop, but you generally pay the price when things go wrong, and you have no idea how to resolve an issue. At least with DTOs, the Core Data aspect of the application is localised in a single location.

One other thing I’m considering Core Data for is to keep track of the posts that were imported. This is to prevent double entries, since the Day One CLI doesn’t have a way to give that information to you. I’m wondering whether it would be worth keeping that information in a separate store. I haven’t explored how multiple stores work with Core Data, and I hope that there are no hidden gotchas associated with doing it this way.

That’s all for this week. I hope to get something written to Day One by the time of the next update.


Projects


Previous post
Weekly Project Update 1: An Experiment Of all the blogs that I follow, there is one type that is a particular favourite of mine. These are posts from Dave Weiner, Marco Arment, David
Next post
Weekly Project Update 3: Ripping The Guts Out I was a bit more productive this week than I was last week. It seems like the balance of two forces acting on my productivity — the anxiety of the