Re: Check on correctness



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,

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

Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: assigning variables in e.g. an if ....
    ... It's a short way of writing something and almost any programming ... language allows basic assignments like that. ... produce bigger and better idiots. ... So far, the Universe is winning." ...
    (comp.lang.php)
  • [EGN] Re: Please any one suggest me some project ideas
    ... >> Georgia Tech did something like this to detect cheaters in ... his students' programming style might well ... "hello world" assignments from a first ... Given the abilities of Mr. Nilges demonstrated previously in this ...
    (comp.programming)
  • NEED a Cobol/TELON IMS/DB2/CICS Programmer/Analyst in Dallas, TX
    ... development on the OS390 using IMS and DB2 databases in a MVS and CICS ... Complete programming and/or design specification assignments as made by ...
    (comp.lang.cobol)
  • Re: Fortran Help...
    ... > class is my last class so I can graduate. ... > the programming assignments for the life of me. ... If the assignments are so easy as you write they are, ...
    (comp.lang.fortran)
  • Re: can project autoassign?
    ... aren't exactly interchangeable programming units, ... time I adjust anything I have to manually juggle a bunch of assignments to ... > Andy Barnhart wrote: ...
    (microsoft.public.project)