Re: Good Habits (was: Re: C question for you old guys ;-))
Re: Good Habits (was: Re: C question for you old guys ;-))
- Subject: Re: Good Habits (was: Re: C question for you old guys ;-))
- From: Oscar Morales Vivó <email@hidden>
- Date: Mon, 9 Jun 2003 17:45:06 +0200
What "good habits" does anyone else have?
A few of mine. Some of them are C++isms (although I think C99 gets them
too). Some are probably personal manias too :P.
- Always use references if a null pointer isn't valid in that place
(for function params, temporary and local variables...). Tends to make
null pointer errors easier to locate.
- Always use the '=' operator only for assignments, never for
initialization (although the quirks of C++ make that impossible in a
few cases).
- Use the logical operator keywords instead of the traditional
operators ('and' instead of '&&', 'or' instead of '||', 'not' instead
of '!'). I find it makes the code far more readable.
- Use comments in then and else clauses if the condition is not
specially trivial. Like:
if(<very complex expression>)
{
// This means Jupiter is in the house of Libra.
...
}
else
{
// Jupiter is not in the house of Libra.
...
}
/*
Oscar Morales Vivs
Eternal Computer Science Student. Master of C++ Templates. Cocoa Nut.
Computer Graphics Illuminati. UI Guru in Training. Dabbler in all
things CS and most which are not.
Web stuff:
http://homepage.mac.com/oscarmv/index.html
*/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.