Tesugen

Decorating Applications

In object-oriented design, there’s a concept called _decorator It’s one of the 23 patterns described in Design Patterns. Simply put, it’s about wrapping an object in one or several other objects, each of which adds some kind of functionality.1

I want Mac OS X to support this for apps.

An example, but first a little background: I’ve been using PulpFiction ever since it released. No news aggregator suits me perfectly, but using PulpFiction’s filters I can tailor it to near perfection. I subscribe to about 250 feeds, of which a handful are from weblogs I want to read everything from, 50 or so are from blogs I want to read every now and then, and the rest are weblogs I want to read more sporadically. The way I’ve configured PulpFiction, it filters posts into three general categories: my top favorites, other favorites, and the rest.

But PulpFiction is too slow. It just can’t handle hundreds feeds and a database containing more than 20,000 articles. When I launch it and it begins pulling in the feeds, it beach-balls for ten minutes and consume 70-80 percent CPU time. Unacceptable.

So, last night I imported my feeds into NewsFire and spent a half hour reading. It doesn’t offer the rich functionality of PulpFiction, but it is a much more pleasant experience to use it. As anything Mr. Watanabe creates, it both looks good and feels good.

If only I could wrap it!

I would write an app decorator that added an iTunes style My Rating control to the blue bar displaying the name of the feed.

This would add a rating property to the meta data of the feed. My decorator would hook into the sorting of the left column, and sort posts according to the rating of the feed. The decorator would give my top favorite feeds a high score, my other favorites a slightly lower score, and the rest would be sorted according to the default. Also, my decorator would randomly assign a higher score to posts from “the rest,” in order to diversify my news consumption.

Apps should be simple, like NewsFire, and everyone should be able to decorate them easily – and to share their decorators with others.

Some already do this. My former colleague Hao Li, for instance, decorates Safari with his Saft plug-in. He hijacks Safari by posing as an Input Manager, and adds stuff like full-screen browsing, preservation of open tabs, incremental search, etc. But this isn’t an actual plug-in. Safari isn’t extensible the way Firefox is. Input Managers aren’t really intended to be used like this. What Hao has done is to inspect the private internals of Safari, hooking himself into message chains in real time, intercepting calls, piggybacking. With each new release, chances are that Apple has changed something that breaks Saft.

Well-behaved Mac apps, besides adhering to the UI guidelines, also are scriptable, which means that they expose parts of their private internals in public interfaces. Automator will probably take this even further. If decorating was supported, apps would have to expose not only internal functions and objects, but events and hooks, as well as allowing decoration of their UI, possibly by marking regions where controls can be placed2.

1 The wrapping objects in the Decorator pattern have the same public interface as the wrapped object, so other parts of the code can do its thing, ignorant of whether it’s doing it on the unwrapped object, or one with six onion skins of extra functionality.

2 UI decoration can’t be completely free. When a public API is published, it is a contract specifying things that won’t change. There’s no contract between Saft and Safari. For UI decoration, designating specific regions for decoration is a contract specifying that those region will be preserved.

The above was posted to my personal weblog on November 7, 2004. My name is Peter Lindberg and I am a thirtysomething software developer and dad living in Stockholm, Sweden. Here, you’ll find posts in English and Swedish about whatever happens to interest me for the moment.

Tags:

Related posts:

Posted around the same time:

The seven most recent posts:

  1. Tesugen Replaced (October 7)
  2. My Year of MacBook Troubles (May 16)
  3. Tesugen Turns Five (March 21)
  4. Gustaf Nordenskiöld om keramik kontra kläddesign (December 10, 2006)
  5. Se till att ha två buffertar för oförutsedda utgifter (October 30, 2006)
  6. Bra tips för den som vill börja fondspara (October 7, 2006)
  7. Light-Hearted Parenting Tips (September 16, 2006)
Bloggtoppen.se