Colby, John
JColby at dispec.com
Wed Aug 11 14:02:25 CDT 2004
I'm in love! <huge grin> JWC -----Original Message----- From: Charlotte Foust [mailto:cfoust at infostatsystems.com] Sent: Wednesday, August 11, 2004 2:42 PM To: Access Developers discussion and problem solving Subject: RE: [AccessD] Naming Conventions I've read code complete, and I agree with that approach. I suspect it is a carryover from structured programming disciplines, where you *always* declared the variables just in time to use them in that routine. Structured programming sometimes seems to be an uneasy fit over Object Oriented and Event Driven code, but I still declare variables at the top of the routine, just before they're used. I don't normally declare variables at the module level, except in classes, I pass arguments between routines instead. If you want to be picky, in structured programming you never have a routine that does more than one thing, so the top of a routine *is* as close as they can get. :-} Charlotte Foust -----Original Message----- From: Arthur Fuller [mailto:artful at rogers.com] Sent: Wednesday, August 11, 2004 10:24 AM To: 'Access Developers discussion and problem solving' Subject: RE: [AccessD] Naming Conventions Your post reminds me of something I read in "Code Complete", by Steve McConnell (a book I consider essential reading for any programmer, irrespective of language(s) used). It was my custom to put all variable declarations at the top of a given module, but Steve recommends against that, and suggests instead that declarations ought to go as close as possible to the portion of the code in which they are used. That struck me as counter-intuitive but the more I thought about it the more persuasive I found his argument. Lots of code is produced using copy/paste. If the declaration is right above the loop or whatever, it's simple to grab it along with the loop itself, for use elsewhere. And the compiler sorts it all out anyway, so what you're really talking about is readability for humans not machines. From that p.o.v., why should you learn about a variable until immediately before it is used? Arthur