|Welcome to the Monastery|
Re: Maintainable code is the best codeby theorbtwo (Prior)
|on Oct 03, 2001 at 03:21 UTC||Need Help??|
I like your post in general, but have one thing to say to this: Noooooo!
Take a look at what you're replacing this with. It's even worse then what you started with. "hashFor" is just 7 characters that repeat "%". No gain except making every expresion that they appear in that much longer. And longer code is harder to understand then shorter code that does the same thing (in general). The mind boggles when it sees long things. The fact that much of the code isn't really doing anything but telling you what you already know doesn't come into effect until later. It's the same reason that obvious comments make unreadable code.
A good replacement might be:
Everything is grouped by use, names are descriptive, but no longer then is acatualy useful.
However, both of us are missing the real problem here. To quote Linus: "To call a global function 'foo' is a shooting offense". WTF is "stuff"? Telling the reader what stuff is is an absolute neccessity. You should always be able to tell what a varaible should contain, and with container varibles, by what it's indexed. If %evens is "for even numbers", why isn't it an array in which only even indeces are used? Perhaps "for even numbers" isn't really what the author meant, but rather "of even numbers".
I reccomend everybody read Linus' coding standards. Not because I think Linus is a God, but because they're damm good coding standars. (If you don't have the kernel source on your box, BTW, look at the Linux Cross Reference.)
Thanks, James Mastros, Just Another Perl Abbot