[AccessD] Naming Conventions

Charlotte Foust cfoust at infostatsystems.com
Wed Aug 11 13:41:54 CDT 2004


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 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte
Foust
Sent: Tuesday, August 10, 2004 11:30 AM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] Naming Conventions


Yep.  I do it, and my boss hates it, although the other developers
appreciate it.  My boss feels that that extra green text makes the code
*hard* to read and is unnecessary is short routines.  My feeling is that
I never know what might get inserted into the middle and it's easier to
keep track if you comment the code when you write it.  I had an
instructor who insisted on this kind of commenting even for declarations
and at the end of a function or sub.

Charlotte Foust


-- 
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list