I generally tend to keep a rule by Robert C Martin, who emphasizes on code.
He states that for every for statement, I should only have one statement in it. Example,
for(int index=0;index<size;index++)
{
doSomething();
}
doSomething(); gives me the ability to reduce the dependency on that for statement and increases my change for re-usability. Also, never use magic numbers. Here is an example,
for(int index=0;index<9;index++)
{
doSomething();
}
the above for statement reduces the chance of variable re-usability,easier to change and can be used throughout the system without having to repopulate them throughout your system in terms of a problem.
Typically for statements are used for iteration of ranges. For a procedure that requires iteration based on condition, I would use a while loop.
while(Inventory.isEmpty())
{
removeInventoryItem();
}
Again, not a scripter. I just love to program