April 27, 2024
MarkBernstein.org
 

Development

So, Thursday I had planned to implement a nifty feature that had been on the wishlist roadmap for two years. The point is to embed some objects other than images in the text presented in the Tinderbox text pane. The task requires a class called NSTextAttachment which is poorly documented, even by Apple’s standards. Here’s how it went.

Thursday morning: OK: this should be fine! Wonder why I waited so long? Let’s get it done.

Thursday midday: That’s strange: it works OK, but as soon as I save a reload, it’s gone. Hit Stack Overflow: almost nothing of use. Hit Google: one old post suggests a really clumsy way of doing persistence. Try it: it works — until I save the file. At that point, *>poof<*.

Thursday night: This is a total disaster. Perhaps there’s a solution, but this isn’t it. Unpack “Oh shit, Git!” (which is hilarious and very good) and rewind to the start of Thursday morning. Abandon hope, also the project.

Friday morning: Wait! Think about it the other way around. Imagine that you were the Apple engineer who wrote this mess. The main task is just embedding images in text, and that works. Yet this engineer wrote the API we have, which seems cockamamie, and also wrote the persistence we have, which is completely undocumented. If I had wound up in this place, what might I have been thinking about? Use that guesswork to start over.

Friday evening: What do you know? It works! By “it”, I mean a non-functional trial balloon, but by George, I think we’ve got it!

Saturday morning: What we’ve got, in fact, is a mess. Code smells from here to the horizon: indecent exposure everywhere, downcasts, and weird hacks that have to be explained in comments. Up with this we cannot put: place all Saturday plans on hold, because this cannot wait.


Aside from the total rollback, in which I indulge perhaps once or twice a year, this is pretty much what it’s like.