/* Tell the user if foo is bar. */
if( foo == bar )
{
fprintf( stdout, "Foo is bar." );
}doif( foo == bar )
{
/* Foo is bar, so tell the user.*/
fprintf( stdout, "Foo is bar." );
}As the above code shows (sorry for the C, I don't do ++), I'm a fan of putting spaces between parentheses and what they contain, and of putting opening braces on separate lines from the code that calls them. To me, it looks cleaner, but it's certainly a matter of debate.You are not logged in, either login or create an account to post comments
I would suggest reading Code Complete by Steve McConnell, which is a book dedicated to the basic principles of software construction, and one of three books sitting on the table in front of me right now.
Ahead of time I try to think of a naming convention that I like for my variables and functions then try to stick to it for that project. Finally, I go back a lot and re-edit code that I've written, replacing variable names that no longer make sense.
Like writing a book, your code will never be absolutely perfect, it's a matter of continuous refinement.
posted by onalark at 9:29 AM on July 28, 2008