Worst class naming examples?
November 19, 2007
I’ve had the pleasure to work with some good developers over the years, but even good developers some times have examples of not so good code in their past. My first ’shopping cart’ system put prices in a user’s cookie and used that for final calculations. Yes, I was an idiot. I’m not above making mistakes. I generally don’t make the same ones over and over though - I graduate to bigger and better ones.
When I was learning object-oriented design, one of the few things that clicked early on was the concept of the class - the blueprint which was used to ’stamp out’ multiple instances of an object. A class name would be a noun, obviously, right? I’ve worked with code, however, that had classes with verbs for names (”class buildMessage”), and recently overheard a coworker talk about a class with an adjective for a name (”class boxy”).
What’s the worst class naming examples you’ve seen in the wild?
Did you like this post? Buy me a hot chocolate!
Posted in




November 19th, 2007 at 3:48 pm
A Java application made in India. The name of the 5 classes were quite unpronounceable. We first thought Sanskrit was used in place of English to describe objects until we discovered a strong relationship with the names of the 5 developers…
November 19th, 2007 at 4:06 pm
I’ve seen redundant names before. Things like class MessageClass.
November 19th, 2007 at 4:12 pm
Maybe not ‘worst’, but certainly, amongst the largest (which some folks instantly qualify as ‘bad’)
see: http://ws.apache.org/xmlrpc/apidocs/org/apache/xmlrpc/server/RequestProcessorFactoryFactory.html
The names being:
RequestProcessorFactoryFactory.RequestSpecificProcessorFactoryFactory
and
RequestProcessorFactoryFactory.StatelessProcessorFactoryFactory
BTW, this one made the rounds a few months ago.
November 19th, 2007 at 8:57 pm
I once worked on a website that was originally programed on the cheap somewhere in Asia. Amazingly enough the original code base was sound. What was not sound was the subsequent work done by a (no bs) meth addict.
There was decently named variable that had over timed turned evil. The name of the variable was something like ‘accountid’. At some point another variable ‘acountid’ came into existence. The variables had the value and the code base was about evenly split in usage. The sad thing was that misspelled variable was not the stupidest thing I saw.
November 19th, 2007 at 9:18 pm
[...] Orginal post by Planet PHP [...]
November 20th, 2007 at 3:29 am
I dont think an adjective is *that* bad since you could have multiple noun objects that subclass an adjective and it kind of makes sense. I still wouldnt use “boxy” though.
November 20th, 2007 at 5:48 am
[...] Worst class naming examples? Posted by Richard@Home Filed in Quote Of The [...]
November 20th, 2007 at 10:42 am
Mixing multi languages in Namings of classes, Methods and Variables.
HATEHATEHATE
$meinPortal->addUser($aUsers);
/*
where $aUsers is
November 20th, 2007 at 1:16 pm
Sebs, it looks like part of your comment got cut off. Sorry! Repost if need be. I worked in an environment where some of the devs wrote comments in their native language, so we had both english and chinese comments in the code. Very hard to debug.
November 20th, 2007 at 1:16 pm
I once worked with a developer who created a system for transforming media files based entirely on the Transformers cartoon series. (This was years before the recent movie release.) Her classes were all literally based on characters from the show, e.g. “OptimusPrime”, “Cybertron”, etc.. It all made perfect sense to someone familiar with the cartoons, I suppose, but unfortunately most of the dev team were too old to fall into that category.
My other pet peeve is guys who use one-letter class or variable names. At the same aforementioned company, we had a class called “G” that did all kinds of important and mysterious stuff. The author of that one was an Orthodox Jew and former Adobe employee, so maybe that all fits somehow.
November 20th, 2007 at 1:21 pm
Holy cow, that’s bad (’transformers’ names). I don’t think you ever shared that one with me before, but it’s good. Perhaps classnames based on 70’s bands would be better for those of a certain generation?
class SealsAndCrofts
class PabloCruz
class LogginsAndOates extends WussRock
Yeah, I just saw “viva ned flanders” this weekend.
November 20th, 2007 at 3:52 pm
“I dont think an adjective is *that* bad since you could have multiple noun objects that subclass an adjective and it kind of makes sense. I still wouldnt use “boxy” though.”
Interfaces I can see being adjectives.
Class Foo Implements Boxy {}
However, not so much on the class side.
November 21st, 2007 at 5:05 am
Mixing multi languages in Namings of classes, Methods and Variables.
HATEHATEHATE
Mixing multi languages in Namings of classes, Methods and Variables.
HATEHATEHATE
$meinPortal->addUser($aUsers);
where $aUsers is
['benutzername']
['passwort']
Name Database tables and cols even in english, so that fetch() and alike give you $myEnglishvarname['mykey']
A very bad thing is using array key that consist not only of one key case. Example:
$array['myKey']. This is prone to be a source of errors
It can get worse.
1. A DB Table contains a serialized PHP array in $array['myserializeddata'] and is deserialized to
$array['MYSERIALZEDDATA'] = unserialize($array['myserializeddata']);