Good Habits (was: Re: C question for you old guys ;-))
Good Habits (was: Re: C question for you old guys ;-))
- Subject: Good Habits (was: Re: C question for you old guys ;-))
- From: Shimaron Greywolf <email@hidden>
- Date: Mon, 9 Jun 2003 09:15:12 +0200
In fact, when I started out with C++, I intentionally picked a style guide
that I now follow. Many good thoughts there. I totally agree with writing
a comment when you intentionally leave something out. This really helps one
to find bugs in a code review.
Another example is switch() {...} statements. Everybody knowns that a
"case" without a "break" falls through to the next case. Yes, danger's
lurking in the shadows. I write my code like this:
switch (i) {
case 1:
blabla;
break;
case 2:
moreblabla;
// Falls through
case 3;
evenmoreblabla;
break;
default:
oops:
}
Another thing may also be noted here: I _always_ include a default case that
is executed if no other case matches. Good spot for an exception in many
cases.
What "good habits" does anyone else have?
Chris
_______________________________________________
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.