Apr 28, 2010

Diamonds

What makes a great programmer? As the saying goes, It's hard to define, but I know it when I see it.


Clarity. Easy to read code. Classes that seem so trivial, but do something really complicated. The kind where you smack your forehead and say "Of course, why didn't I think of that..."

Code that is self evident. You know how it is: when a great programmer leaves, it's really easy for someone else to take ownership of their code. When a terrible programmer leaves, the code left behind is such a nightmare, everyone wishes the programmer was still there, so they didn't have to maintain their code.

Bad programmers get lots of inquiries to explain their code. Good programmers don't even know someone is using their code, cause no questions are asked...  The flip side of that is that bad programmers get to feel really important - they're needed when people use their code...

Minimal documentation. Documentation that does exist, explains why something is done, and not what is being done. If you need documentation to explain what is being done, the code needs fixing.

Meaningful method names and parameter names. Short classes and methods.

Good programmers are great communicators, as code is a type of communication.

Great code is elegant.

And then comes Joel and provides a wider view on Spagetti code, with his post: "Things You Should Never Do, Part I"
"Back to that two page function. Yes, I know, it's just a simple function to display a window, but it has grown little hairs and stuff on it and nobody knows why. Well, I'll tell you why: those are bug fixes. One of them fixes that bug that Nancy had when she tried to install the thing on a computer that didn't have Internet Explorer. Another one fixes that bug that occurs in low memory conditions. Another one fixes that bug that occurred when the file is on a floppy disk and the user yanks out the disk in the middle. That LoadLibrary call is ugly but it makes the code work on old versions of Windows 95."

So let me qualify and say that great new code is elegant.  Bad code isn't elegant even when it's new.