Ill-monikered Variables and Creative Class Naming

by Tim O'Brien


This blog entry mentions bad variables names; among them is the always confusing $data. My favorite quote from Andy Lester's post is:




'Of course it's data! That's what variables contain! That's all they ever can contain. It's like you're packing up your belongings to move to a new house, and on the side of the box you write, in big black marker, "matter."'




Are you bored by lame variable and class name? If so, give us some examples? Or, write a haiku on creative class naming. How you use this forum is entirely up to you.


4 Comments

jimothy
2004-05-18 04:30:22
Names
I'm probably betraying the confidence of former colleagues, but once upon a time, I came across this code (in Java):


BufferedOutputStream buffy = new BufferedOutputStream(...);


Aww, how cute. The theme continued a few lines later with a variable named "angel". Incidents like this make me disagree with your encouragement of creative variable names. In fact, when I read that section, I was never quite sure if you were being sarcastic or not, since that advice seemed so out-of-line with your preceding advice.

tmo9d
2004-05-18 06:48:57
Names


I take it your former colleague was a fan of Buffy the Vampire Slayer. There is no sin in making it interesting, but I do think that "cute" code is a mortal sin. I'm not encouraging buffoonery or lightness, but "active naming". I've seen many times where a set of programmers are so bored with coding on a particular system that they start to resort to offense and explicit in-code comments as a form of communication.



What I talk about is more applicable to Class naming than variable naming. People often tend to forget that they can use real-world analogies; instead, they get bogged down in "pattern-speak". I'm only trying to encourage people to use bolder language.



I would prefer the cute name to something like this:



BufferedOutputStream outputStreamToHoldTheData =
new BufferedOutputStream(...);



I am happy for you that these are former colleagues.


jimothy
2004-05-18 11:28:02
Names
I do want to make it clear that I continue to have tremendous respect for these former colleagues, their taste in televison notwithstanding. (-: I certainly did not mean to disparage anyone.


To paraphrase Will Rogers, I've never met a programmer I didn't like.

russellmiles
2004-05-19 08:21:57
Names
There are some examples out there when it comes to creative class naming that can't help but make me smile.


An absolute beaut of an example was the 'StinkyException' that one of the best software engineers I've had the fortune to work with named her 'quick noddy test exception'.


This exception was hidden away until it was raised in front of a customer to some general embarrassment for the poor engineer in charge of the demo.


Where would software be without a sense of humor!