What does 'meaningful name' mean? (For software developers and not only)
Today we had a discussion at work.
The focal point was a cite from a book 'Steven C. McConnel. Code Complete, Second Edition':
Arrays are often indexed with the same variables that are used for loop indexes. If you have a one-dimensional array, you might be able to get away with using i, j, or k to index it. But if you have an array with two or more dimensions, you should use meaningful index names to clarify what you’re doing. Meaningful array-index names clarify both the purpose of the loop and the part of the array you intend to access.
My POV was that names like i, j, k are never meaningful (although sometimes it's clear in the context what they mean).
The opposite one was that i, j, k are meaningful if their meaning may be quickly established in the context.
Whose understanding of the word 'meaningful' is correct?
I believe i,j and k are never meaningful names. They are symbols taken from algebra.
I understand "meaningful name" as one that communicates what the variable is representing. For example
if you are iterating over an array of words, each word has several characters, then names like "word_index" and "char_index" would be meaningful names.
That's correct. i,j, and k are arbitrary names, as the previous commenter said more like algebraic variables. A meaningful name more truly represents the value or values you are storing in the array.
In computer programming, meaningfull means that the software will understand them by default. You will not need to define them again. Otherwise, you need to define them.
software developers? not all software deveoplers use the same software. You has to specify which language is used. Such as Pascal, C, C++, visual basic etc. In general speaking, meaningfull means the built in functions.
Thanks, guys, for your comments!
Answering Generation Gap's question, we use a few languages (Delphi, Java, php), but the code my team analized was written in Delphi. I didn't aimed to ask only programmers. I've just thought they definitely must know the answer, while other people may or not.
- Help me plz
- اريد التحدث
- ¿Miembros Españoles, Dónde Estás?
- Unterschied zwischen "Tschüss" und "Auf Wiedersehen"
- Have you ever been in Bethlehem (Palestine)?
- Life is life!
- Hi,everyone,I wanna learn English.