I give credit to BigSpaceShip for this idea found at this post. Thanks your guys rock!
The thing that has always bugged the heck out of me is the naming convention for loop iterator variables.
Example: loop One would be named “i”, I always thought because it was i for iterator. What about the Second loop named “j”. Whats that stand for? and what do you name the Third loop if there is one? Well if your like me that always kinda confused you and felt convoluted.
Now here’s the cool new idea, use “i” as in Roman Numerals.
Example: loop One would be “i”, loop Two “ii”, loop Three “iii”, ect….. Now that makes sense!
Not only can you quickly identify what loop iterator your looking at but you now have a reason for name the next iterator if you need to.
I know this is not ground breaking or big news but it’s this type of thinking AS3 needs more of and I will continue to promote it so long as I see it.

















After digging a little bit more I found the naming logic for naming loop iterators. It’s just the alphabet starting from i. I did not know that befor, nor have I found my self trying to use more then three or four loops at any given time. So the supporting statement made by Bigspaceship was that some people find them self using reserved variable names such as x and y. That has to be a butch of loops to get to x and y. Even then I can see how this error prone if you do use that many loops. The fact the naming convention start at “i” in the alphabet makes it less intuitive if you did not all ready know the naming convention. Such as my self for never concluding that j was just not some arbitrary name for people that find them self using more then one loop. Why do iterators start at i? and what do you do after z?
But now that I think of it, using a var name with more then one character could cause slower performance.
Programmers, typically, are considered to be a subset of mathematicians, and accordinly receive considerable schooling in mathematics, so just as x, y, and z are used for position in geometry and trig, i, j, and k are the natural choice for indices just as they are in higher-level math (rotations, integrals, summations, etc.).
Tradition, basically.
That said, the roman numerals notion is interesting, but far too easy to mess up or confuse the number of i’s. It breaks one of the basic “rules” of variable naming — avoid names that can be easily confused with one another.
As far as what to do when you get to z…
Given that ActionScript and most other modern languages support closures to one degree or another, the iterators can begin anew with i in each function. And if you get deeper than three iterators in a single function, consider it a free-and-easy indication that refactoring is probably a good idea… or at least as an indication that using descriptive iterator names will definitely make that code dramatically more readable, maintainable, etc. And z? If you get that far, you are (almost certainly) doing something wrong.
I tried this in a project I’m currently working on. I noticed that “Find and Replace” was more difficult to use when I wanted to change the name of the variable.
First off.. Josh I’m bummed I missed the first AS3 meeting
Please put me on the mailing list and Ill try to make it to the next meeting.
My comments on the post:
Interesting concept, but it seems it would get crazy after a second.
The concepts of i, n j comes from the study of mathematic matrices. A dimensional matrix is describes columns and rows by m X n where m is the row and n is the column. For instance you could find a particular place in the matrix by ith row of the jth column. I believe the concept of dimension is reason it is used in looping constructs and arrays which are associated with a tensor. blah blah blah… ha ha.. any way..
Cheers
Don T