Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Aysel Kaya   on Dec 10 In MS Office Category.

  
Question Answered By: Christina Ramirez   on Dec 10

Yes - very subjective. Same as I never use type prefixes on variables (like
"dbl", etc). I've seen just too many instances of people changing the
variable type but not changing the prefix - causing confusion.

> A big advantage for me to declare at the top is to have them together so
> that I *can* sort them and zap the unused. I also think it's neater... But
> what the heck.

Ah, you see, I don't have that problem. :-) If I remove the usage of a
variable, I also remove its declaration - because they are on the same line.

> I'd actually tend to declare DaysPerLeapYear as a constant... It aint
> gonna
> alter for a loooong time, and prefix it with a type and sort of scope.

Oh yes, so would I. As I said in my message, my mind was blank at the time
and the example was stupid.

But why use a type and scope prefix? The compiler will tell you if it's out
of scope and the type is immaterial. (Actually, I do use a prefix for
really global variables - a lower-case "g" - but I avoid that type of
variable as much as possible, anyway. Absence of that "g" denotes that it's
not defined in my global variables module and is therefore either private or
module-level public - in which case it would be used from elsewhere with dot
notation.)

I suppose my emphasis is on the readability of the flow of the algorithm in
the code, and I leave the respective compilers to tell me when I'm
mis-matching types or am out of scope. As an OO programmer from the
beginnings of OO, I also structure code  severely, and don't tend to have
lots of variables in subroutines or subroutines long enough to "lose"
definitions in.

Perhaps my pet hate in the impact on readability comes in the "C" type of
languages, where it is an old convention to declare constants using
upper-case letters and underscores in their names - as distinct from the
mixed upper/lower of variables. To me, this completely mucks up the
readability flow, for a gain of nothing. The compiler will tell you quickly
enough if you try to change a constant. (And, of course, if you then decide
it should be a variable, you need to do a global change to put its name into
the correct form. Or just leave it looking like a constant, which is what I
see more often.)

So. My _personal_ preference is not to encumber the code with things that
the compiler can handle just as well, but instead to concentrate on making
variable names as meaningful about their purpose as possible.

Share: 

 

This Question has 11 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Code Cleaning Was: Re: Can't open excel file Or get search suggestion and latest updates.


Tagged: