|
-
Aug 4th, 2004, 08:13 AM
#1
Thread Starter
Fanatic Member
Here a dim, There a dim, everywhere a dim, dim
Is anyone else having trouble reading code you hacked together, mere days or even hours ago
because of the obscene amount of Dim statements?
I'm coming in from VB6.0 and it was very tidy when you put all your dim's a the top of the procedures and functions
and New'd any objects you might need.
Now, with vb.net it seems that dimming in the middle and everywhere else is just "what you do".
You are allowed, even encouraged, to overload your dims with things like
dim x as objtype = new objtype.overload(blah blah)
It's one of the bigger hurddles for my small mind to, er, leap over.
Most of the other stuff is gel-ing nicely, but the idea that I 'dim on the fly' seems blasphemous.
Not sure if I should chalk this up to progress or if it's a step backwards in the grand scheme of things.
Course the scheme of things seems to be to make .NET complicated enough so
that ordinary hacks will have to pay to get a program written for them.
-
Aug 4th, 2004, 08:30 AM
#2
Member
Now, with vb.net it seems that dimming in the middle and everywhere else is just "what you do".
All other languages use this scheme. So id consider it a step forward. Not to mention OOP,Overloading etc.....Everything is just better.
-
Aug 4th, 2004, 08:40 AM
#3
Frenzied Member
You can always put your dim statements at the top.
One advantage of putting dims for complex functions like file browsers and the like is that it keeps the prerequisites for the function in the same viciinity of the code as the function call, and also, if the function is in a loop that does not get executed, I don't think the resources get allocated for the call. (???) If so, wouldn't that make the code run faster? Just a guess ...
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
-
Aug 4th, 2004, 09:22 AM
#4
As webtest stated it is now considered better to keep your declarations as close to their first use as possible.
In C# I've noticed that if you declare a variable at the start of a function, and it does not get assigned, maybe because of a loop condition then the compiler returns a warning stating this might happen.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|