From Ken.Williams at thomsonreuters.com  Tue Feb 15 23:43:16 2011
From: Ken.Williams at thomsonreuters.com (Ken.Williams at thomsonreuters.com)
Date: Tue, 15 Feb 2011 16:43:16 -0600
Subject: [Rd] Request: Suggestions for "good teaching" packages,
 esp. with C code
In-Reply-To: <AANLkTikOVVyMF0Xjn2Re9JLekvKoi2euZdZodEJnN9WM@mail.gmail.com>
Message-ID: <C9805C71.23A27%ken.williams@thomsonreuters.com>


On 2/15/11 4:35 PM, "Gabor Grothendieck" <ggrothendieck at gmail.com> wrote:

>I think the real good programming practice is to have a single point
>of exit at the bottom.

I disagree, it can be extremely useful to exit early from a function.  It
can also make the code much more clear by not having 95% of the body in a
huge else{} block.


>If that is how you program all your functions
>then you don't need to explicitly put a return in since it always
>returns from the bottom anyways and the return would just clutter your
>code.

For someone else reading your code, they wouldn't know that you always do
this unless they're very familiar with your coding style.  Even then, it
needs to be manually checked by inspection because nobody sticks with the
"rule" 100% of the time, so it renders the benefit moot.

--
Ken Williams
Senior Research Scientist
Thomson Reuters
Phone: 651-848-7712
ken.williams at thomsonreuters.com
http://labs.thomsonreuters.com



[Rd] Request: Suggestions for "good teaching" packages, esp. with C code
Ken.Williams at thomsonreuters.com