R
Robert Jacobson
Hello all,
If I have a class called "Foo," is there a preferred naming convention for
iterating through each Foo instance in a collection of Foos? I've seen
several different variations, even in the MSDN documentation:
#1:
For each Foo as Foo in Foos
...
Next Foo
This variation is direct, but a bit ambiguous since it's using the same name
for the Foo class and the Foo instance. (I know that the "Foo" in "Next
Foo" is optional -- I'm just including it for clarity.)
#2:
For each MyFoo [or aFoo, TheFoo, etc.] as Foo in Foos
...
Next MyFoo
This variation eliminates the ambiguity by adding a prefix to the instance
name. However, it seems a bit too "cutesy" for me.
#3:
For each f as Foo
...
Next f
This appears to be the C# convention, for better or worse. Terse and to the
point.
I tend to use the first variation, but wonder if this makes my code less
readable. Does anyone have a preference for any of these, or any other
variations? I don't want to start a religious war, but am curious about
whether there's a consistent "best practice."
If I have a class called "Foo," is there a preferred naming convention for
iterating through each Foo instance in a collection of Foos? I've seen
several different variations, even in the MSDN documentation:
#1:
For each Foo as Foo in Foos
...
Next Foo
This variation is direct, but a bit ambiguous since it's using the same name
for the Foo class and the Foo instance. (I know that the "Foo" in "Next
Foo" is optional -- I'm just including it for clarity.)
#2:
For each MyFoo [or aFoo, TheFoo, etc.] as Foo in Foos
...
Next MyFoo
This variation eliminates the ambiguity by adding a prefix to the instance
name. However, it seems a bit too "cutesy" for me.
#3:
For each f as Foo
...
Next f
This appears to be the C# convention, for better or worse. Terse and to the
point.
I tend to use the first variation, but wonder if this makes my code less
readable. Does anyone have a preference for any of these, or any other
variations? I don't want to start a religious war, but am curious about
whether there's a consistent "best practice."