Learning Takes Time

6 April 2006 at 15.19 • in Trifle, Mac, Programming

I often feel that Trifle is progressing at a snail’s pace. Shouldn’t I have gotten more done by now? But in my clearer moments I remember that I’m not just developing an app, I’m learning a new platform (Mac OS X), framework (Cocoa), and language (Objective-C).

Learning takes time. There’s no getting around it. I’m not just talking about the direct time it takes to learn something, but also the false starts and fruitless investigations that go along with it.

Last week I thought up a couple of different ways to handle custom columns in Trifle. I picked a solution and spent several days coding it. This week I realized that it was the wrong choice; the other way would be simpler and easier. So I had to rip out the work I’d done and start over.

Or take Core Data. Trifle is an awfully database-ish app, so I had to investigate whether Core Data made sense for it. I’ve learned quite a bit about Core Data now, in multiple stints, but it still isn’t the right choice for Trifle.

I could call that wasted time, but it isn’t, really. It’s just part of the overhead of learning to operate in a new environment. Besides, learning is one of my favorite things to do. Maybe that’s what attracted me to programming in the first place: there’s always something new to learn.

Booklog: March

3 April 2006 at 10.52 • in Books

I read a lot last month–not just the books below, but also the first two volumes of Gene Wolfe’s Book of the Short Sun. But I’ll hold off on writing about those till I finish the third volume.

Fiction
Neverwhere — Neil Gaiman
Gaiman’s first solo novel, based on the BBC miniseries he created and wrote. An entertaining, relaxing book to reread; Gaiman’s light tone leavens a dark story.
Nonfiction
The Way of Chuang Tzu — Thomas Merton
Ancient Taoist writings rendered by a modern Catholic monk–an unexpected combination that really works, especially in the anecdotes of Chuang Tzu’s life.
Soul Proprietor — Jane Pollak
Another book on lifestyle entrepreneurship. The “101 lessons” format is a little forced, but Pollak makes up for it by telling an abundance of good stories.
Speak What We Feel — Frederick Buechner
A deeply thoughtful look at the lives of four great writers, and how the darknesses they faced were reflected in their work. As soon as I saw the writers Buechner chose–Shakespeare, Twain, Chesterton, and Gerard Manley Hopkins–I knew I had to read this.
A Whack on the Side of the Head — Roger von Oech
A classic creativity book that’s been on my read-that-someday list for years. I’m glad I finally read it: few books are both fun and thought-provoking, and this is one of them.
More Ready Than You Realize — Brian McLaren
McLaren tries to reclaim evangelism from its modern distortion into arm-twisting salesmanship. Not a lot here that I haven’t seen elsewhere, but it’s well-presented.
Universal Principles of Design — Lidwell, Holden, & Butler
I tracked this down after reading Don Norman’s glowing review. He’s right, it’s good.
Designing Interfaces — Jenifer Tidwell
A catalog of interface design patterns for software, general enough to apply to both desktop apps and web apps, but specific enough to give useful guidance.

I (Still) Want an Editor

28 March 2006 at 19.31 • in Mac, Programming, Overleaf

I want a Mac-native text editor that supports:

  • syntax-aware automatic indenting
  • syntax-aware search (project-wide, both “find definition” and “find all uses”)
  • arbitrary programming languages
  • proportional fonts

Is that too much to ask? Apparently, yes. I haven’t found a single editor that implements all four. TextMate can’t handle proportional fonts. SubEthaEdit can’t indent intelligently. XCode isn’t extensible. Et cetera.

All this is reminding me why I started working on Overleaf. Too bad I don’t have time for it right now. Maybe I’ll get back to it in the sweet by and by after I ship Trifle.

Breaking a Retain Cycle

23 March 2006 at 15.53 • in Programming

Today I came across a retain cycle that Cocoa’s usual conventions can’t break. Trifle’s collections keep their items in an NSMutableArray, and items keep their collections in an NSMutableSet. Since Cocoa collections always retain their members, this creates a cycle.

I toyed with the idea of allowing the cycle, and then breaking it with careful manual deletion. But that’s way too easy to get wrong, especially with the undo manager in the picture.

An NSValue can contain a nonretainedObjectValue, so I could store NSValues in the set instead. The NSValues would be retained, but the collections inside them wouldn’t be. The extra layer of indirection would be a bother, though.

NSHashTable is a better answer. It’s a non-object data structure that provides the same functionality as a mutable set, but lets you specify whether to retain/release member values. The only catch is that I’ll need to write a few simple methods to expose it to key-value coding (search for “unordered” in Tiger’s release notes to learn more).

Of course, life would be better if I didn’t have to spend time thinking about retain cycles. Cocoa does a decent job papering over the limitations of reference counting, but I’d still rather have real garbage collection.

Update: An even better solution for this problem is to use toll-free bridging. CFSetCreateMutable(NULL,0,NULL) gives me a non-retaining set that I can just cast to NSMutableSet and use.

Exceptions to Every Rule

13 March 2006 at 18.55 • in Trifle

An answer to my rule dilemma: declarative rules with exceptions. A collection is defined by declarative rules in the same way as a smart playlist. But items can also be added and removed manually, creating exceptions to the rules.

At the implementation level, each collection tracks two sets of exceptions. One set contains items to always include, because the user put them there. The other set contains items to always exclude, because the user took them out. There are a few corner cases that get tricky, but overall, it’s not too hard to do the right thing.

This approach abolishes the distinction between regular collections and smart collections. Instead, those two cases become endpoints of a continuum. A regular collection is just a collection with no rules (only exceptions!). A smart collection is just a collection with no exceptions (only rules).

Now that I’m thinking in these terms, I’ve realized that this is part of the plan for Chandler’s collection model. So this isn’t an original idea. That’s a good thing, though: if nobody was using this model, I’d drive myself crazy trying to figure out what fatal flaw kept people from using it in their apps.

Declarative vs. Imperative Rules

10 March 2006 at 12.38 • in Trifle

Should Trifle’s rules be declarative or imperative? I’ll give examples instead of definitions: spreadsheet formulas and smart playlists are declarative, while email filter rules are imperative.

Declarative rules are the success story of end-user programming. Millions of nonprogrammers create and use them daily. But in the form of smart playlists (and their smart-* kin), they have some problems. For instance, they make it hard to fine-tune their contents. If the query for a smart playlist gets you almost there, the only way to get all there is to either tweak the query some more (add or remove conditions) or tweak some items (change them to fit/not fit existing conditions). The Chandler folk have been wrestling with this, trying to come up with a more flexible model.

Imperative rules are much more flexible. Lotus Agenda provided powerful imperative rules that could be triggered by various actions. But that power and flexibility had a price. As Agenda’s creators said, “The results of cascading program-initiated actions often surprise even experienced users…” And surprise is a Bad Thing here.

So I’m not happy with either approach at the moment. To use Adam Bosworth’s terminology, declarative rules are simple but not sloppy, while imperative rules are sloppy but not simple.

Rules Redux

10 March 2006 at 11.31 • in Trifle

I’m having second thoughts about cutting rules. My arguments against them don’t seem convincing anymore.

“Rules are a major schedule risk.” Yes, but I’m not on a particularly tight schedule. Sure, I want to ship expeditiously, but a few months either way won’t make a big difference.

“Rules need to be done right or not at all” — otherwise I’d be stuck supporting a broken rule model. But I think this is actually an argument for rules. By designing rules now, in concert with Trifle’s overall data model, I have a better chance of making a single coherent system.

“Trifle will still be a useful application without rules.” True. But the question is whether Trifle will be a distinctively interesting application without rules. I doubt a simple list/table editor would generate much if any buzz, and for a shoestring operation like mine, no buzz means no sales.

Besides, the whole reason I started this experiment of independent development was to create an innovative and useful app. If I reduce that to a lowest common denominator by eliminating the tricky-but-interesting features, not only will I fail to excite potential users, I’ll fail to excite myself. And that will quickly suck all the fun out of this (ad)venture.

So now I’m in design mode, trying to find a rule model that works. It’s a frustrating endeavor, ’cause I don’t like any of the solutions I’ve found so far, and I don’t feel like I’m making much progress. But that, too, was part of the reason I started doing this: to find a challenge.

Booklog: February

1 March 2006 at 13.42 • in Books
Fiction
Busman’s Honeymoon — Dorothy Sayers
The last Lord Peter novel; my only disappointment is that I don’t have more of them left to read. The mystery itself is downplayed in favor of character relationships, but Sayers again makes it work.
Lord Peter — Dorothy Sayers
A collection of all the Lord Peter short stories. I’d read most of them before, but saved the last two (involving Harriet and the Wimsey children) till now.
Nonfiction
The Last Word and the Word After That — Brian McLaren
McLaren concludes his trilogy of fictionalized dialogues (that started with A New Kind of Christian) with thought-provoking ruminations on hell.
Take and Read — Eugene Peterson
An annotated bibliography of Eugene Peterson’s favorite books. As you might expect, most if not all of his picks have a theological angle.
Purple Cow — Seth Godin
I kept hearing kudos for Seth Godin’s books on marketing, so I finally read one. I liked it: it’s rare to find a business writer with writing ability and something to say.

Scripting Automated Tests

27 February 2006 at 13.08 • in Trifle, Programming

When using AppleScript, most people see GUI Scripting as a last resort: it’s a lot nicer to say “select first collection” than “select row 1 of table 1 of scroll view 1 of splitter group 1.” But the very qualities that make GUI Scripting unattractive—such as fragility, and dependence on explicit mouse and keyboard actions—make it a great tool for automated testing. I don’t even have to wait till Trifle is scriptable: I can write tests now.

AppleScript, though, is far from my favorite programming language. Thank goodness there’s appscript, a bridge that lets you use Python to script AppleEvents. Appscript can’t paper over all the oddnesses of AppleScript, but life becomes much easier with all of Python at my disposal.

For instance: I can drop down to the Objective-C level to verify something using PyObjC. I can use any of several test frameworks. And I can verify saved Trifle documents using Python’s XML support. This is Python’s sweet spot: libraries to connect to just about everything.

A Year After Switching

23 February 2006 at 20.29 • in Mac

It’s been a year since I switched to the Mac. I was hoping for a better user experience, and I got all that and more. OS X and its included apps are a joy to use (well, we don’t talk about the Finder, right?). The Unix underlayer keeps me happy in ways the old Mac OS never could. Cocoa is a fun and productive framework to program in. And I get to use some top-notch applications:

I thought I was happy with web-based RSS readers, but NetNewsWire changed all that. It’s the perfect example of an application that Just Works. On the strength of that, I bought MarsEdit as well, and I’m using it to write this post.

I’m just beginning to use VoodooPad Lite to keep notes about Trifle. I used to keep a local wiki on my Linux box for stuff like this, but the edit/view modality was too annoying. VoodooPad solves that nicely; I’ll probably buy the full version soon.

And then there’s Quicksilver, probably the single best reason to switch to the Mac. Try it, use it, learn more about it.

I wonder how I should celebrate the one-year mark. Now that my iMac’s warranty is up, there’s nothing to stop me from getting a second display and doing some screen spanning

« Previous PageNext Page »