Want clean code? Stop using the editor.

Want clean code? Stop using the editor.

Eric Smith
Eric Smith

December 21, 2007

Recently I was adding some accessors to a ruby class on the fly, and I kept getting confused by a certain code block.

The code isn’t particularly complicated, just creating a quick accessor to get at the underlying hash.

eval <<-eof def>

Yet I had a couple bugs simply because without the editor to give me hints, the code was that much harder to follow.

This turns out to be a blessing in disguise, as I am forced to write extremely clean code just to keep from confusing myself. Opening up the String class cleans this up a bit, and removes duplication.

So the next time you think your code isn’t as clear as it could be, or maybe if you think it’s perfect, try reading it without any syntax highlighting. If you can still follow it quickly and easily, then maybe it doesn’t entirely suck.