View Single Post
  #6 (permalink)  
Old 07-11-2009, 4:00 AM
cjard's Avatar
cjard cjard is offline
VB.NET Forum All-Mighty
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Apr 2006
Age: 65
Posts: 6,442
Reputation: 807
cjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond repute
Default

Quote:
Originally Posted by Robert_Zenz View Post
* Always declare variables outside of Loops
Not necessary. The compiler will move the declare out of the loop in the real program. Declare your variables as close to where you will use them as possible and keep their scopes small for more readable, logical code

Quote:
* At very large collections use a normal For Loop instead of a For Each (one variable declaration less)
Using For Each sets up an enumeration which can be many hundreds of times faster at accessing a collection than a positional based indexer (Linked list for example must count 99 items before it can return you the hundredth, a LinkedList of 100 items iterated using a positional indexer must perform 5000 skips to return all items: don't do it).
Do not advocate positional indexing purely on a variable declaration saving (nanoseconds)

Quote:
* Try to avoid unnecessary calls
Again, nanoseconds, and youre advocating making code one huge long unreadable procedure for the sake of minor inlining performance (which the compiler will perform if it feels the need) gain. It's not worth it: readable code first!
__________________
DW1 DW2 DW3 DW4 DNU PQ
Reply With Quote