Three Monkeys, Three Typewriters, Two Days

April 20, 2005

Interface writing and how NOT to do it

Consider the initial checkin of the tree box object interface. Note the complete lack of useful documentation. Try to figure out what to pass to the getCellAt() method. Just try. But it's OK because it's not part of build, right? Or so the thinking seems to go.

That interface, and many others like it, have survived more or less in this exact state until now. Implementations are broken because people didn't know what to implement; callers are broken because they couldn't tell what to pass. Things get passed based on trial and error; sometimes they work due to hacks in the callers or implementations, sometimes they do not.

So I've resolved two things:

  1. I will try, to the utmost of my ability, to make sure code like this either doesn't land at all (not even "not part of build") or at least is not allowed to be enabled in the default build until the interfaces are documented. If people want it on badly, that's great—that means they have lots of incentive to document.
  2. I will try, again to the utmost of my ability, not to try to cause bodily harm to people who checked in code like this in the past, if and when I actually meet them. I can't offer any guarantees on this front, though. Having several days of my life completely eaten up because they were too lazy to spend half an hour documenting their interface does not make me a happy camper.
Posted by bzbarsky at April 20, 2005 12:07 AM
Comments

It seems that every line of that code was meticulously documented. Of course, none of those comments may actually be "useful". (IANAP)(1)

(1) IANAP: I am not a programmer

Posted by: Peter Lairo on April 20, 2005 2:33 AM

Well, it is much better in v 1.33 that is true :-)

Peter: look at that version to see the difference between a plain comment that brings no clue and a good comment, you'll see it even if YANAP :-)

BTW, the whole comment for this method seems one character to the left in LXR...

Posted by: franCk on April 20, 2005 2:53 AM

Wow. Is that David Hyatt? I mean, THE David Hyatt, the same that is currently "leading Mac users into idolatry"?

OTOH, checking the log I see that he made the code a lot better very quickly. In fact he posted v 1.2 explaining how to call getCellAt 17 minutes after 1.2. Sure you can't compare that to leaving code in that state for years...

[PS: I am a Mac user, in case you wonder. Leave Dave alone!! :-) ]

Posted by: themask on April 23, 2005 10:00 AM

Yes, that is THE David Hyatt. No, he didn't add any documentation for getCellAt. Documentation for getCellAt was added in April 2005 (3+ years after the interface was created), and not by David Hyatt.

And no, I have no plans to "leave Dave alone." Shoddy work is shoddy work, no matter how much you idolize the perpetrator.

Posted by: Boris on April 24, 2005 2:29 PM

The box objects were never considered to be real interfaces. They were just scriptable hooks so that the XBL glue code could communicate with the render object from JS.

While I won't defend the lack of documentation (all headers should be well-documented ideally), I will point out that the climate back then was such that I was working insane hours trying to do many many things at once.

Maybe that doesn't excuse it, I don't know, but I thought maybe you would appreciate my perspective.

Posted by: hyatt on April 30, 2005 5:03 PM

David, I'm aware of the climate at the time. I believe that climate was a major management error on the part of Netscape, and that the Mozilla project has trying to recover from the effects climate for a while now, with only limited success, as we can see. A little bit less rushing back then could have meant a much better and more maintainable codebase for years now. :(

The "real interfaces" distinction doesn't really hold water, though. XBL glue code is exactly what's ended up buggy because the authors of said code didn't really know what the box object code did under the hood.

Posted by: Boris on May 1, 2005 2:18 PM

A little less rushing then would have meant there'd be nothing worth talking about now at all. We'd certainly have nowhere near the same level of infrastructure, for instance. It's quite possible we'd never have gotten the products far enough off the ground to get the level of funding or corporate involvement the project has received.

Posted by: Ian Hickson on May 2, 2005 7:06 PM

Who needs funding! Hippies onwards!

Posted by: me on May 2, 2005 7:29 PM

Ian, the corporate funding issue is one that certainly bears thinking about; I wasn't involved in that, so I don't know what the scene looked like. From a pure engineering perspective, I think a lot more time has been lost to this approach than gained by it.

Posted by: Boris on May 2, 2005 7:37 PM

There's a lot more to bear in mind in product development than just the engineering perspective. Especially before you publicly criticise someone's code in a way they might find offensive.

Posted by: Ian Hickson on May 3, 2005 4:43 PM

Quite frankly, the post was meant to be offensive. If nothing else, there was plenty of time after the crunch was over when things could have been documented. They were not. Instead, people kept hacking around the same old issues, adding more and more crud.

Posted by: Boris on May 3, 2005 5:35 PM

You were complaining about the initial checkin. That's what I was responding to.

(In anycase, the person who did the original checkin moved to different projects before the era of "plenty of time" arrived. I don't know who you had in mind for doing all the documentation.)

Posted by: Ian Hickson on May 4, 2005 7:36 PM
Post a comment