Exploration Through ExampleExample-driven development, Agile testing, context-driven testing, Agile programming, Ruby, and other things of interest to Brian Marick
|
Tue, 09 Jan 2007The end of my one-typo coding rule (updated) Long ago, two bugs made a profound impression on me. One bug was in a Unix kernel function that did something-or-other with inodes (integer indexes into the file system). The function header looked like this:
The original programmer had somewhere used an
The other bug was because a programmer used From these experiences I devised a rule: Don't create two identifiers one typo apart.
That rule made me an outcast. Other programmers laughed at me because I
didn't use However, today I'm working in Java with Intellij IDEA. Just now, I realized one constant needed to be two:
When using them, I don't type those full names. Instead, I type Many more identifiers are now one typo apart. Rats. 1 They also laughed at me for writing C conditionals like this:
instead of
(For the non-C programmers among you, the second form is one typo
away from That was back when I was working on Common Lisp for the Gould PowerNode, and one C programmer looking at my code said, "Is that some kind of weird Lisp thing?" I don't think I ever convinced anyone to do it the safer but awkward way. That was not the first time I noticed that aesthetics trumps cost-benefit analysis. (In case you're wondering, I'm not changing my two constant names. I'm thinking that it'll be too hard to come up with memorable, meaningful names that are not a typo apart, so I'm abandoning my rule. Maybe a bad idea, but I don't claim to be any less swayed by aesthetics and personal preference than anyone else is.)
UPDATE: I just spent ten minutes tracking down a problem caused by
using |
|