For Loops and Variables
- From: "Jason Cavett" <jason.cavett@xxxxxxxxx>
- Date: 5 Apr 2007 08:47:28 -0700
This was a discussion my co-worker and I had awhile back and I was
curious what the group thought.
for(int i=0; i < someValue; i++) {
// do stuff
}
The discussion was that the use of the variable "i" was not good as it
should be named something that means something (arrayCounter or
whatever) so it is easier to understand the code. The reverse
argument was that using the "i" variable as a counter was an okay
practice and it is alright as long as it is the only variable doing
this (all other variables are well named). Convenience of typing "i"
versus "someLongVariableName" was the argument on this side.
I'm just curious what everybody here thinks about this. Are there any
standards on this topic?
P.S. I purposely didn't state what my position was.
P.P.S. Both parties agreed that meaningful variables were a good thing
overall.
.
- Follow-Ups:
- Re: For Loops and Variables
- From: Chris Uppal
- Re: For Loops and Variables
- From: Eric Sosman
- Re: For Loops and Variables
- From: Oliver Wong
- Re: For Loops and Variables
- From: Gordon Beaton
- Re: For Loops and Variables
- Prev by Date: Re: String[] to String
- Next by Date: Re: Eclipse not display warning if try catch is not present
- Previous by thread: Problem with browser tabs and sessions
- Next by thread: Re: For Loops and Variables
- Index(es):
Relevant Pages
|