In many code reviews they suggest dont use i, j as variables..Is there any specific reason to avoid using i, j in for loop.
e.g
for (int i=0; i<10; i++ )
{
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The basic guideline is to use variable names that are meaningful.
iisn’t very meaningfull, however, inside a for loop it often isn’t a problem, when the scope of the for loop is really small. One letter variables for loop variables is very intuitive for most developers, and when that variable is only used in one or two lines, it isn’t that big of a deal. When the scope gets bigger on the other hand, it gets harder to follow whatiactually is. But than again, you should normally not have more than one line of code (just a method call) in a for loop anyway, to keep your code as readable as possible.Still, even with a loop with a body of a single line, I would prefer a more meaningful name than
i. For instance, what exactly does thativariable represent? If you can give it a more meaningfull name, such asindexorrowNumber, you should do so. It makes your code more understandable.