Tuesday, January 15, 2008

Black On One Side And White On The Other

Eric recently mentioned that he and his coworkers were debating the merits of the following two ruby code snippets.

if object

if object.nil?

If object is nil, both of these expressions will evaluate to false. The question was, should the former be allowed? I've had my thoughts on this before,  but I stopped myself this time and thought about the issue at a higher level. We're talking about six characters here. What's the big deal? The first time a Ruby developer encounters this issue, he'll ask his buddy, Mr. Tubes, who will tell him the answer. Then he's good forever in that language. So we're really talking about the extra typing (ignoring the fact that if object represents a boolean, then we might have issues). But then this was said:

FxBx: but otherwise, yeah, im all for if object referring to its mere existence
KxDx:Yeah, it's intuitive

Eric dropped the I-word. The programming blagoblog has been abuzz lately about intuition (here and here (yeah I know one of them, is old, but it was recently recirculated)). Some people think intutive means familiar; that viewpoint is at least partially true. Tech reviewers and regular joes criticized Microsoft Office 2007's new interface, the ribbon, because it wasn't intuitive. What they really meant was that it was different and they couldn't figure it out. The QWERTY keyboard and mouse are only intuitive because we're familiar with them. Jef Raskin has said that the word "intuitable" makes more sense than "intuitive" because a user will either intuit an interface or not. 

An interface designer has to balance introducing new concepts with existing ideas, using the old patterns to bridge to the new ideas. A completely new system would frustrate many users who would be unable to intuit the system, while a completely familiar system would add no new value. 

Anyway, I get fired up about intuition and interfaces, but the point I'm trying to make is that spending time worrying about coding convention similar to the one above is wasted time. Unless you're marketing your product to a very specific subset of users who will only understand one way to do things, then just pick your favorite and move on.

Post a Comment
All rights reserved. Take that!