Re: Check on correctness
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Tue, 04 Jul 2006 15:54:49 -0400
It is the nature of for statements that the first and third clauses have side effects. So
indeed I exclude those from the "no assignments" or, more generally, "no side effects"
rule.
Whenever I find assignments embedded in code I'm working on (and it is never my code), I
just rip them out, and replace them with separate assignment statements.
joe
On Mon, 3 Jul 2006 10:40:29 -0700, "Tom Serface" <tserface@xxxxxxx> wrote:
Hi Joe,Joseph M. Newcomer [MVP]
I assume you're excluding for() statements from this rule. For example:
for(int i=0; i < something;++i) {
}
is very common and a proper form of declaration and initialization
especially now that we have decent for scope handling. This keeps the
variable local to the loop and is a consise and coherent way of declaring
nad setting the initial value.
I agree with you on other types of statements. For example:
if(x=1) {
}
would work, but not likely how the programmer intended. Fortunately, we get
a nice fat warning for this one.
Tom
Of course, this compiles in either release or debug modes
"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:u2fea21k8h9gj67kope08hp8uft4h0chh2@xxxxxxxxxx
You need to do two things to become a better developer:
Never, ever under any circumstances embed assignments in any other
construct. Not in an if, not in a while, and most especially not in an
ASSERT.
Embedded assignment is a very poor programming methodology, and serves
little if any useful purpose at any time and should be abandoned as a
programming technique
Never, ever, under any circumstances make any document or view class
visible
to a dialog. Dialogs should only work on their own member variables or
structures used for communication and not know about anything else outsdie
themselves.
joe
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- Check on correctness
- From: tim@xxxxxxxxxxxxxxxxxxxxxx
- Re: Check on correctness
- From: www.fruitfruit.com
- Re: Check on correctness
- From: tim@xxxxxxxxxxxxxxxxxxxxxx
- Re: Check on correctness
- From: Joseph M . Newcomer
- Re: Check on correctness
- From: Tom Serface
- Check on correctness
- Prev by Date: Re: Threading problem
- Next by Date: Re: getdlgitemtext
- Previous by thread: Re: Check on correctness
- Next by thread: Re: Check on correctness
- Index(es):
Relevant Pages
|