in reply to IYO, what is elegant code?
First, Stein's code is more efficient. While Stein names that tune in 2 notes, I named it in 10. That's an obvious one.
Second, elegant code makes use of existing modules. Not only that, but it makes efficient use of those modules. Stein obviously has much more familiarty with the methods in the modules than I do. What I wrote a whole subroutine for, he wrote in one line.
My last observation was that elegant code is fluent with powerful programming tools and how to apply them. Even though the problem I was trying to solve was ripe for a recursive function, I didn't see it. Even if I did see it, I probably wouldn't have figured out how to write it without pulling some hair out of my skull. Stein, however, obviously tossed off his recursive function as an afterthought. To me, this is probably the most important mark of elegant code. It really shows the programmer knows his/her stuff.
Update:That last comment reminded of something else I wanted to add about comments. My comments are way too wordy and get in the way. I obviously think way too my hard about my code. Stein's comments are much more concise and to the point.
Well, that's what I learned. Hope it helps you gain some insight.
$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff";
$nysus = $PM . $MCF;
Click here if you love Perl Monks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: IYO, what is elegant code?
by stonecolddevin (Parson) on Jul 13, 2003 at 04:34 UTC |