http://www.perlmonks.org?node_id=992176


in reply to var comparison

/me nods ...

I learned a huge lesson about computer programming when I first encountered the following comment in source-code:

Dig me up and I’ll fix it then.

(Blink!)

But, you know, it’s true.   Even though none of us likes to think about mortality, our source code will probably out-live us, even by a considerable interval.   And, even if it does not, we always need to write for maintainability.   If digital computers are not quite fast enough to execute our object-code now, you can be sure they will be in the near future.   But the source-code will still be there, regardless.   Therefore, above all other things, make your intentions of the moment abundantly clear, and strive to do so in a way that will create the least amount of headaches for your successor. (Too bad for you ... sux that a bread-truck was at just the wrong place at just the wrong time ... and by-the-way so were you).   Change will come, and your if-statement will not last forever.

Most of all, the person who makes that change wants to be able to make his or her change without disrupting, and therefore having to re-test, your original source-code.   Don’t get hung-up about “efficiency.”   Don’t indulge in cleverness of-the-moment in sacrifice of maintainability of-the-future.   If you do that, people just might throw AOL floppy-disks at your tombstone out of spite.

Replies are listed 'Best First'.
Re^2: var comparison
by nemesisgus (Acolyte) on Sep 06, 2012 at 21:57 UTC

    I'll remember that one!

    Wow! I had never guessed how an apparently simple question would lead us to such a kind of deep thoughts.

    You are right, of course. I have to confess myself too worried about efficiency at the expense of clarity very often.

    Tip of the day: "clarity over efficiency". Or, at least, over small improvements in efficiency.

      Thanks.   (It makes me feel a wee bit younger.)

      Moore’s Law pretty much wiped-out any consideration of “efficiency” in my book, a couple of decades ago ... with the notable exception of the very valid edge-cases that my esteemed colleague, BrowserUK, routinely and legitimately encounters in his daily work.   Aside from such performance über alles edge-cases (and therefore, IMHO “as a general rule”), maintainability and simplicity trump just about every other imaginable concern in this business.   It is frankly, literally, true that ... “at 1 billion ops per second (give or take...) these days, no one can hear you scream.”