On May 01, 2007, at 14:50 UTC, Brendan Murphy wrote: > This whole discussion misses the point. Maintenance of the code > "trumps" all the merits of putting DIM statements in any other place > but the top of the method since putting DIM statements within the > code are negligible at best. If you scatter your DIM statements > within your code you make your code harder to read.
I strongly disagree. Code is easier to read when the variables are declared right where they are used. Benefits include: 1. No need to scroll all the way back up to the top when you spot a variable to see what its type is. (Though granted, in RB, this is less of an issue since you can get that information by mousing over it, but still, that's unnecessary mousing.) 2. When reading the declaration, it's clear where the variable was *intended* to be used, and when it's no longer intended to be used (i.e. where it goes out of scope). Understanding the intentions behind the code is critically important when maintaining it. 3. Those intentions are actually enforced by the compiler, so if you inadvertently reuse a variable where its value no longer has any sensible meaning, it will fail clearly at compile time rather than fail mysteriously at run time. > Which is more > important, your time as a developer or some negligible benefit? If > your time is only worth $1 an hour, then have at it an write > unmaintainable code, but the professional developers typically earns > $50 or more an hour and making your code harder to read is rather > short sighted. I definitely agree with this. That's why I always put the declarations in the innermost scope, and as close as possible to the first use of the variables being declared (except in extreme cases where optimization may drive moving them out of a loop). Best, - Joe -- Joe Strout -- [EMAIL PROTECTED] _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html>
