On the Naming of Variables

Nov 30, 2006 01:13

Sometimes I hate trying to name things in my programs. I work hard to try to come up with really descriptive, clear, standardized names since I think that it makes the programs much easier to understand. My programs may be a bit more verbose than some but they also tend to read pretty well. Besides, long names are why we have M-/ in Emacs.

Sometimes the right name is immediately apparent and it just jumps out and writes itself into the code. Other times, it's rather difficult. I know the Extreme Programming folks talk about finding metaphors as descriptions for what a program is supposed to do. Admittedly naming something in a program is pretty much a matter of finding a metaphor for that entity. But it feels like sometimes, even when you know what the metaphor for something should be, it still doesn't quite feel right as a name. I think sometimes there's more overlap between writing good prose and writing good code than we programmers will admit. In both cases just finding the right word can be a challenging struggle.

This evening I'd planned to do some refactoring in my renderer and merge a pair of classes together. I'm happy with what I plan to call the new class but was stopped in my tracks trying to thing of a name by which the references to the instances should be propagated around. Oh well, I'd rather take a little more time to think it through and get it right.
Previous post Next post
Up