Thursday, October 7, 2004

To the original writers of this code...

Dammit, what the hell were you thinking when you wrote this crap? "Hmm, I need this bit of functionality. Oh, here's some code which does that. I'll copy and paste it into my code."

Have you people heard of functions? You know, those reusable bits of code they taught you on the first day of CS 1? Hell, we're not even talking about "advanced" concepts such as recursion, which is covered in the fifth lecture.

Oh, look. You wrote your own sort loop. It runs in O(n4) time. You know, there's this nifty algorithm called bubble sort which runs in O(n2) time. I think it's lecture seven.

No, I don't want to be reminded that they pay you to write this stuff.

By the way -- and I know this comes as a shock -- there's a mechanism which allows you to put arbitrary text into your source code which is ignored by the compiler/interpreter. They're called comments. Yes, I know it sounds a bit weird -- why would anyone want to put arbitrary stuff into their code that is ignored by the computer? Well, see, it doesn't have to be completely random. You could, say, describe what it is you're trying to compute. Maybe mention that there's an obscure side-effect you're relying upon in some call. The type of stuff that might help others reading your code understand what it's supposed to do.

Next week, we'll talk a bit about indentation -- yes, something else which is ignored by the computer but helps others trace out where your spaghetti loops start and end.

No comments: