GenderRenderer, GenderEditor and unfortunate class names

So the other day I’m looking at somebody’s code and notice a class name that caught my attention; “GenderEditor”. I think it was just your normal JTable class to show a “gender” property, but I thought it was kind of funny because the class name implied you could use this program to switch a user’s gender very easily (with no surgery!).
I talked to the developer and we had a good laugh about it. Then I noticed in the code a class called “GenderRenderer”. Well, you don’t have to use a lot of imagination to figure out how this class could be potentially a problem (what should we use to represent gender … hum).
There’s nothing wrong with these class names of course, but it made me think about how hard it is sometimes to come up with good names for our classes and how easy it is to come up with some awkward and sometimes embarrassing names.
I can’t remember any similar to GenderEditor, but I do know somebody that got carried away with naming everything *Broker. UserControllerBroker, GroupManagerBroker, SaveTheDolphinsBroker. If that wasn’t enough, then actual “broker” implementations just appened “Impl” at the end of the name, making things even more convoluted; UserControlerBrokerImpl, GroupManagerBrokerImpl, etc. I guess good descriptive names are nice, but you can get carried away trying to define what the object does in the name. We do have comment blocks in most languages, so sometimes it’s best to just say what the thing is supposed to do there.
I’m also not a big fan of putting a big “I” in front of interfaces. IUser, IConsumer, ICreditCard, this convention is used a lot by Microsoft and IBM. You look at the Eclipse code and it is littered with it. I see the point though, sometimes you want to make clear people separate interface from implementation, but we do have IDEs that let us know quickly and visually what is a class and what is merely an interface.
The again, having some basic naming conventions is often better than none at all. As long as you apply a bit of common sense and make sure you read the names you are using out loud, you won’t end up with weird names or potentially offensive sounding classes.
Filed under: Software Development on February 15th, 2008

Hi Augusto,
Not on about that gender stuff again!! Beginning to worry about you mate
Bernie