MLUG: Re: [MLUG] Quick programming question on style
Re: [MLUG] Quick programming question on style
Email address obfuscation in effect -- please click here to turn it off.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

On Jun 3, 2005, at 11:21 AM, Dave Lloyd wrote:

On Fri, 3 Jun 2005, Jeremy Hinegardner wrote:


This looks to me as if someone was planning on putting some
success/fail/debug code in but just never did it. 


Always, always, check your return values.

Amen, amen, amen. :)


Personally I use the first style, but switch it to:

    if (1 == testcase) {

That way if you make the common mistake of using a '=' instead of an
'==' you'll get a compiler error.  I have no idea where I first liearned
this but I tend to use it in any langugae.  Putting the constant on the
left side of the comparison prevents accidentally assigning a value to
the variable.


Ooo.  Now that's a handy tip.  Not that I've seen it used much.


--dlloyd

I think there was a Linux Journal that talked about this at some point, although I can't remember now, but I did see this a while back.  Course, I completely forgot about it until now - good reminder :)
Jason

/--------------------------------------|---------------------------\

| Jason McIntosh                       | CELL: 573-424-7612        |

| Webmaster, thinker, Programmer, etc. | WORK: 573-884-3865        |

| http://poetshome.com/                |                           |

|------------------------------------------------------------------|

|"How should I know if it works?  That's what beta testers are     |

|for.  I only coded it."                                           |

|(Attributed to Linus Torvalds, somewhere in a posting)            |

\--------------------------------------|---------------------------/

GnuPG Key:  http://poetshome.com/about/jmcintosh_mlug.missouri.edu.gpgkey


_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members