Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^6: Burned by precedence rules (fail() if "false";)

by gwadej (Chaplain)
on Dec 28, 2008 at 21:22 UTC ( #732931=note: print w/ replies, xml ) Need Help??


in reply to Re^5: Burned by precedence rules (fail() if "false";)
in thread Burned by precedence rules

I have often said that I have learned as much from the really bad code that I have maintained as I have from the really good code I have maintained. (That applies to both my code and other people's code.)

If a value of FALSE that is not false doesn't scare you enough, I won't tell you what I found FOUR defined as...<grin/>

G. Wade


Comment on Re^6: Burned by precedence rules (fail() if "false";)
Select or Download Code
Re^7: Burned by precedence rules (fail() if "false";)
by MidLifeXis (Prior) on Dec 29, 2008 at 13:01 UTC

    I still have to say that my favorite maintenance horror is the block that had (including comments) the $language equivalent of

    $x = 1; $x = 1; # Just to be sure

    *shudder*

    --MidLifeXis

      Some folks (i'm talking about you MidLifeXis) just don't understand humor :)

        Looking at the rest of the code, it was definitely *not* humor ;-)

        --MidLifeXis

Re^7: Burned by precedence rules (fail() if "false";)
by swampyankee (Parson) on Dec 31, 2008 at 00:48 UTC

    No doubt it was originally defined as FOUR = 4, but then somebody was told to change it to 42 or π. This is why I tend to avoid setting constants like THREE = 3. I find it rather annoying to have constants with clear names that lie. After all, complex code is self-obfuscating; it doesn't need any help.


    Information about American English usage here and here. Floating point issues? Please read this before posting. — emc

      Something like that.

      This is why I started using the term magic constants a few years ago to complement magic literals. Everybody agrees that magic literals in code are a bad idea. But, what happens when the constant you chose to replace is with provides no more meaning or abstraction...magic constant.

      A constant like FOUR provides so little information that it would have been better to leave the original literal 4 in the code.

      G. Wade

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://732931]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2014-09-21 10:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (168 votes), past polls