On May 1, 2007, at 11:27 PM, Rubber Chicken Software Co. wrote:

> But even in C++, with the Dimming not automatically initing a
> variable, it's especially crucial for me to put the variables up top,
> so i can easily see that I am initing them properly.
>
> The issue is the same - I like the way it looks. And if I'm happy, I
> write happy code.
>
> All programming guidelines aren't, and shouldn't be, so subjective.
> But I think this one is.

If you are defining variables and not initializing them at the same  
time, you are asking -- no begging -- for problems later down the  
road.  That is because you are separating related sections of your code.

The only reason that this one is so subjective is because for years  
(and years and years), the only way to write code was to declare all  
of your variables at the top of a block.  That is no longer necessary  
with the latest versions of languages, and that is because local  
declaration of variables is a form of data hiding.  Think of  
declaring variables at the top of a routine as the same as the use of  
globals within a program.

You don't want to know how many times that I've seen people "reuse"  
variables because they were declared and initialized at the top of a  
routine.  I can't count the times where someone has reused a variable  
in newly-inserted code and destroyed the initial value, which caused  
problems in the original code.

-- 
Glenn L. Austin <><
Computer Wizard and Race Car Driver
<[EMAIL PROTECTED]>
<http://www.austin-home.com/glenn/>


_______________________________________________
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