On May 1, 2007, at 12:11 PM, Brendan Murphy wrote:

> Glenn L. Austin wrote:
>> That is absolutely and patently incorrect for proper maintenance of
>> code -- putting the declarations of variables as close as possible to
>> their use is one of the basic tenets of good software design.  If you
>> can scope the variables inside of a block so that they aren't
>> available outside of the scope of the block is even better.
>
> That is your opinion and not necessarily a tenet of good software
> design.
>
> Reading code is similar to reading a book. If you bury your DIM
> statements, you make it harder to read. Knowing where your
> declarations are makes it easier to understand the code. If a book
> had its table of contents randomly spread throughout the chapters,
> the result would be confusion. If your eye has to scan the code to
> find the declaration, you have wasted your time. Knowing where
> your DIM statements are speeds your comprehension rate up.

Perhaps it speeds your comprehension rate up, because you expect to  
find dim statements at the top of the method.  Having become  
accustomed to block scoping, I find that it slows me down, because I  
need to keep all of those variables in my brain while reading the code.


>
> The big problem is programmers are selfish. This means they write
> code that looks good to them for their own consumption and not for
> other people to read. They are not thinking of how it will read to
> others. Scattering your DIMs is not doing others who read your
> code a favor. The number one time waster is trying to understand
> code that someone else has written. This FAR outweighs the the
> refactoring argument you use. Readability means the code is
> understood faster which makes it easier to refactor!
>
> Gathering all your DIMs in one spot is just one way to make your
> code more readable, but there are even bigger fish to fry in
> the maintenance of code. Far better is to thoroughly comment your
> code which tells the reader what it does. Having to expend time to
> figure out what each line of code does, is a huge waste of time.
> Most likely, if you are a person who scatters your DIM statements,
> then you probably don't comment your code which speaks to the lack
> of attention to detail which I mentioned earlier and this is
> selfishness (you are not considering others who will use your
> code).


I agree that having to expend time to figure out what each line of  
code does is a waste.  My approach, however, is to write code whose  
intent is clear.  Adding comment that explains what the code does is,  
in my opinion, unnecessary duplication.  Such comments require one to  
keep comments and code in sync. I suppose this means that I'm one of  
those people that does not comment code.

Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to