Friday, August 19, 2005


My PowerBook is running Mac OSX Tiger now for almost two weeks and I have to admit that I like it. I was a bit skeptical when has been announced because it seemed to me that they're moving in the wrong direction. Instead of making the user interface clean and more usable, Apple kept adding new features. I was especially concerned about Dashboard since it looked like a big blob of animated effects. More for marketing than for real users. However, I need Java 1.5 for University and so I finally ordered my copy after resisting for a few months.

To make it short, I was quite impressed. Installation went smooth as usual. The user interface elements are looking a bit cleaner now and Spotlight is unquestionable a big step forward. I still use my favorite tool LaunchBar to start applications, lookup addresses and sometimes navigate through my folders (go and get it, it's really great). But I can now drop all my PDF files and other documents into a single place and don't have to worry about placing them in more or less meaningful named folders (I almost never felt that I got my folder names right). One can assign metadata (called "Spotlight Comments") to documents but I'm not using it much. I feel there is enough data in most documents, so I don't think that adding more (meta)data provides much value.

I even find myself using Dashboard regularly. I'm ashamed but I like these neat little animation effects. I've setup my Dashboard with some quite useful widgets and it's nice to have them all at hand with a single key press. I find people (mostly Windows users) looking at it and saying how unprofessional and kittenish it looks. I think they are just envious because they don't have a nice looking notebook with a cool operating system. They are stuck with Windows OS and got so frustrated about it's mediocrity that they have to attack superior things. They would feel even more frustrated about their bad OS otherwise. Ups, I zoned out at bit.

Dashboard Screenshot

Speed has also improved by an order of magnitude. Well, if you have enough RAM. I've heard from a friend who owns a PowerBook stuffed with 256 megs that things slowed down compared to Panther. I've 768 megs of RAM and my PowerBook got speed bumped. Especially bootup is much faster now.

Of course there is room for improvement. Sometimes it's quite unhandy to have the Dashboard widgets only, well, on the Dashboard. If I try to sum up some numbers from an application using the Calculator widget, I'd like to copy the values from the application to the Calculator. It really drives me crazy to constantly toggle between Dashboard and application. I wish I could pick a widget from the Dashboard and take it into the foreground, putting it back when I'm done.

There are some rough edges in the system (eg my Terminal application sometimes fails to open a new window) but I expect them to disappear with future updates. There's nothing such serious that I'm really annoyed about it.

And I still would like to get the Shelf from the NeXTSTEP Workspace Manager back!!

Friday, August 05, 2005

Avoid Inheritance

I recently had to deal with a part of a system I'm working on that makes heavy use of implementation inheritance. The class hierarchy was quite complex and from the top it looked like a clumsy ball of classes. It took me quite a while to figure out what was going on. Information was spread over the classes in the inheritance tree and information has been duplicated in different classes. To make things even worse, the programmer was using anemic domain objects with almost no behavior. I figured out that the part of the system could be redesigned to be much cleaner and more extensible using almost no inheritance. I always wonder about this inheritance thing. I've talked to people who insist that inheritance, often proposed to be a key concept of today's OO languages, must be good to achieve reusability and maintainability.

But if you look around, it's hard to come up with a real-world example for inheritance. The world is composed, not inherited. Almost every object you see consists of several smaller "objects" working nicely together. Objects can be rearranged and combined in different manners to form new, bigger objects. You can use a stone to build a house or as a bookend. The stone doesn't care. It's perfectly decoupled from it's environment. You may say that you've inherited properties from your parents but in fact you don't "extend" your mother. You extend nothing. You're mother and father gave you a "construction plan" for your body, the DNA. And this construction plan is itself tells other objects how to build and arrange the cells your body consits of (can you feel the patterns emerging?). Still no inheritance in OO sense.

The concept of inheritance is rather abstract. In most OO languages, you define types (Classes) and objects are instances of these types. A type can extend another type. This is probably why one can't easily come up with a real-world example for the inheritance concept. The world is untyped. And even more, it doesn't need these types. Why do programmers? There are prototype-based languages, like Self, which don't have classes at all. They just have objects. New objects are created by copying and customization of existing objects. If you copy an object, it keeps a reference to it's source object and delegates messages it cannot handle itself to this object. This mechanism is called DelegationInhertiance and I like to put the emphasis on delegation. I feel this approach is more Object Oriented than our usual languages like Java etc. In fact, these languages should be called Class-Oriented, not Object-Oriented.

What does this mean for programmers? Well, I certainly don't want to tell you what this means for you. For me, this means that I strive to build systems that consist of small and shy objects working together. I aim to follow the "tell, don't ask" principle. I try to avoid inheritance where I can and favor delegation. Strategies and decorators are often a more flexible replacement for inheritance. I use interfaces to separate the different aspects and concerns of objects. I try to use dynamically-typed languages whenever I can since they make life so much easier.