"A rose by any other name would smell as sweet" William Shakespeare.
There are cultures where people have a sort of public name and a secret or true name that is rarely shared because knowing ones true name gives people power over them. In fact, knowing a name is powerful in all cultures. Consider the difference between calling “hey you” versus calling a child by their actual name. Which way draws them up sharp?
Naming is important in computer programming as well. It’s not always as easy or as simple as beginners assume it is. Mike Zamansky’s post Subtle Errors gives a good example. Having more than one item with the same name causes the sort of ambiguity that computers do not handle well. Some names (identifiers as we often call them in programming) have special meanings. Getting names slightly wrong can cause other problems.
A name can provide a great deal of information to a programmer. To the compiler names are pointers to more information. A variable name identifies a location to the computer. Other information about the data stored in that location is specified in other ways. The computer doesn’t care what characters make up the name. That it is unique is important but not the characters involved. In many programming languages the case of the letters makes two names completely different. People tend to see them as identical.
Beginners often think that “the computer” pays attention to everything in a program the same way people do. That’s not the case though. I’ve had students write comments in their code believing that the computer will read the comment and perform the action. They may also assume that naming conventions, starting all integer valuable names with “int” for example, will influence the computer. Again, not usually the case.
[Note: back in the day, any variable starting with one of the letters “I” through “n” was automatically an integer.]
Names/identifiers can communicate a lot of information to programmers. They are pretty important for sure.It is easy to gloss over them and minimize their importance. Getting them right though is something worth spending time on.
No comments:
Post a Comment