01-10-2006, 03:01 PM
Quote:For scoped variables, yes. But I can picture people declaring *any* stuff wherever and then losing track of variable types and stuff.The key here is initialization - and efficiency. You don't want to declare variables in a function that might exit before they're even used - it's a waste. Furthermore, whenever possible, it's preferred to intialize variables, rather than declaring them and assigning to them later - again, it's a waste. When FB supports classes, this will be even more of an issue: a class' constructor might be an expensive operation to execute. Why construct it to default values only to overwrite those values in an assignment later? It's a waste; it's inefficient code.
I fiscourage it.
Spaghetti code is non-intelligible wild-goose hunts, and it mainly refers to erratic control flow - it has nothing to do with when or where variables are declared. In C, you're forced to declare variables at the start of a function. QB, FB, C++, Java, etc. give you the option - and it's an option you must take if you want to write efficient - and sometimes safe - code. Hell, by default, QB and FB don't even require you to declare variables before use - and it's directly supported by the language!
For beginners and novices alike in the above languages - yes, QB too - I fully encourage variable declaration at the point of initialization. For QBers, this means declaring a variables immediately before their first use. It's just silly not to, IMO.
stylin: