@vlad from moscow
i and i are meaningful names for professinal programmers and have their roots in the FORTRAN |
Well that may be so, but I have seen errors happen time & time again, in this situation. That kind of error is particularly hard to see & the compiler doesn't warn you. On could deduce the problem in the debugger, but I would rather it didn't happen at all, or detect it much earlier. The problems were solved by doing a find replace on the i & j variables, changing them to Row & Col - the error becomes apparent.
The main cause of problems is that i & j look so similar, and they are near to each other on the keyboard. Single char names might be OK for loops, but one could at least could choose letters that look different - like r & c for example. I still prefer a very short or abbreviated word with meaning instead.
You have already made a mistake in your reply -
- you were typing fast weren't you? That shows how easy it is to create a problem.
Now I do respect your knowledge & ability (much much more than mine), but I don't understand why people object to such a simple & possibly error preventing convention.
I guess programming is like maths in a lot of ways, so there are situations where a single char name might be fine. We were involved in a topic quite a while back about factorial(n). Obviously we have x, y, z for coordinates, but should one use Radius or r ; or key & value instead of k & v ; or deg, min & sec instead of d,m,s.
The thing I don't like is seeing a whole page of code with single char variable names, sure we should have comments for variable names at declaration, but I can't help thinking of the weary maintenance programmer who has to understand it all.
Of course one can argue it is personal preference, but I am promoting a convention that might help prevent errors.
I have been involved in a big long discussion about this in the past, hopefully this won't turn into another one.