Re: Check on correctness



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


.



Relevant Pages

  • Re: Check on correctness
    ... wanting to loop forever. ... is very common and a proper form of declaration and initialization ... ever under any circumstances embed assignments in any other ... Embedded assignment is a very poor programming methodology, ...
    (microsoft.public.vc.mfc)
  • Re: Check on correctness
    ... is very common and a proper form of declaration and initialization ... ever under any circumstances embed assignments in any other ... Embedded assignment is a very poor programming methodology, ...
    (microsoft.public.vc.mfc)
  • Re: MFC dll and exe porting to 64-bit
    ... Why the obsolete 'char *' instead of the proper LPTSTR? ... We are no longer programming 16-bit windows in an 8-bit character world, ... string arguments should probably be LPCTSTR, that is, const parameters. ... declaration of the function itself, in context (meaning show the surrounding class ...
    (microsoft.public.vc.mfc)
  • Re: AfxRegisterWndClass() within dll
    ... Take as a fundamental programming rule: writing a static declaration like this a mistake. ... multithreading contexts, and in DLL contexts where the DLLs can be loaded dynamically. ... into "fix our multithreading problems" and this is one of the most common failure modes. ...
    (microsoft.public.vc.mfc)
  • Re: Graphing problem
    ... programming methodology" is not an exaggeration? ... All other poor styles of doing Windows programming methodology emulate Petzold. ... No declaration of this variable is shown. ... The scope and lifetime of a variable should be as narrow as possible. ...
    (microsoft.public.win32.programmer.gdi)

Loading