Performance vs. Readability
It's a trade-off, but I firmly believe that readability is every bit as important as performance when it comes to application code. My approach has always been to code for readability - and, by extension, maintainability - and later, if necessary, optimize for performance.
I suppose this discussion also falls into the avoid-premature-optimization discussion, but today I'm focused on the readability aspect. You see, today I'm wading through 500 lines (well, 478) of Perl code trying to follow the twists of fate that affect the existence of a hash that was built as an array for no good reason.
"Wait, is the 'channel' value index 9 or 13. Shit, what line number had that assignment?"
This endeavor began yesterday and continues today as I try to track down a bug. I'm begging anyone who might be reading this...remember that someone else will probably have to pick up your code one day. Be kind.
push @{$sites{$row[3]}}, "$row[6]","$channellist","\"$row[20]\"","\"$row[21]\",$row[22]";
is a lot harder to read than
push @{$sites{$site['id']}}, "$site['name']","$channellist","\"$site['score']\"","\"$site['blocked']\",$site['industry']";
Granted, Perl isn't all that readable under the best of circumstances, but that's just all the more reason to make it as palatable as possible.




Loading....