Re: how do people feel about exit function from loop



Ralph wrote:
"Larry Serflaten" <serflaten@xxxxxxxxxxxxxx> wrote in message
news:OArXqJs0HHA.3916@xxxxxxxxxxxxxxxxxxxxxxx
"Steve Gerrard" <mynamehere@xxxxxxxxxxx> wrote

* Does the loop index have a meaningful name?
Does "n" count as a meaningful name? :)

I use single letter variables almost exclusively as for loop indexes
used with
arrays, so to me it is.

You must be one of those GenX coders, eh? <g> I come from an era when
3 was the magic number for characters in a variable name. idx (index),
itm (item), row & col, etc... About the only time I'd use a single
letter for
an iterator would be for referencing X and Y coordinates and the
occasional
throw-away test routines.


I use idx 'n such, mainly because it always seemed more readable and more
amendable for search 'n replace. But then I occasionally side to the dark
side and use i% and n&. <g>

Almost nothing I hate more than something like

my_wonderfully_named_array(uselessly_described_index) = _
my_wonderfully_named_array(uselessly_described_index) + _
your_wonderfully_named_array(uselessly_described_index-1)+1

:(

Unless there's a really solid reason for otherwise in a specific application, indices of For...Next loops _should_ be brief and the traditional i,j,k,..., etc. Offhand, I have a hard time of thinking of a place that does justify the use of the longer name that tends to obfuscate more than clarify.

If there's any doubt at all of the intent or the reason for the iterator being the values it takes on, a comment adds that explicitly and doesn't distract further from the code itself.

In VB for deep or long loops I either make sure to declare them as Long or do use the "&" for the performance gain of the Long over the Integer.

imo, ymmv, $0.02, etc., ...

--
.


Loading