in reply to Re: Burned by precedence rules
in thread Burned by precedence rules
I would urge you not to define constants for TRUE and FALSE when the language doesn't provide them.
One of the nastiest bugs I ever had to track down was caused by someone defining these constants slightly differently than the way the language did. We were constantly surprised when !$is_bad, FALSE == $is_bad, and TRUE != $is_bad did not give the same answers.
My favorite readability move for code like this would be to rename the methods (maybe is_done) to work better in conditionals.
In your example, I have a bigger problem understanding why foo returning a true value means that we are not done. If, on the other hand, the method were named is_foo_running it would be easier to understand.
Although I have fought the no magic literals fight for years, true and false are not where I prefer to fight.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Burned by precedence rules (== true)
by tye (Sage) on Dec 27, 2008 at 17:50 UTC | |
by demerphq (Chancellor) on Dec 30, 2008 at 19:50 UTC | |
by ikegami (Patriarch) on Dec 30, 2008 at 20:09 UTC | |
by TimToady (Parson) on Dec 30, 2008 at 20:49 UTC | |
by tye (Sage) on Dec 31, 2008 at 02:14 UTC | |
| |
by demerphq (Chancellor) on Dec 31, 2008 at 00:01 UTC | |
by gwadej (Chaplain) on Dec 28, 2008 at 20:46 UTC | |
by tye (Sage) on Dec 28, 2008 at 21:06 UTC | |
by gwadej (Chaplain) on Dec 28, 2008 at 21:22 UTC | |
by MidLifeXis (Monsignor) on Dec 29, 2008 at 13:01 UTC | |
| |
by swampyankee (Parson) on Dec 31, 2008 at 00:48 UTC | |
| |
|
Re^3: Burned by precedence rules
by webfiend (Vicar) on Dec 26, 2008 at 18:06 UTC |