tags:

views:

4397

answers:

93

Naming things well is arguably Job 1 for professional programmers. Yet we have all suffered from some bad naming choices from time to time. So just to vent a little, what are some doozies that you may have run across?


Just to get things started:

One of our original developers wasn't sure what to call a secondary key - on what turned out to be a primary table for this app - so he called it: DL2WhateverTheHellThatIs.

Unfortunately this system generates entity mappings from the XML, and attributes defined there result in classes, methods, and constants that are referenced through-out the app. To this day it is very hard to find a source file that does not reference this, er, thing! A few actual examples:

DL2WhateverTheHellThatIsBean cos = (DL2WhateverTheHellThatIsBean)itr.next();

String code = getDL2WhateverTheHellThatIs().getCode();

From from = new From("DL2WhateverTheHellThatIs");

String filter = "_dL2WhateverTheHellThatIs._code";

(Very difficult to refactor)

+6  A: 

Single letter variable names.

float p, x, y;

because

 x = sqrt(p * p + y * y);

is much clearer than:

 hypotenuse = sqrt(edge1 * edge1 + edge2 * edge2);
Doug T.
I disagree. (Also, I'm surprised that this is the "worst" naming you've ever encountered.)Plenty of people have documented the rule "name length should be proportional to scope":http://www.jetcafe.org/jim/c-style.html#NamingA short function named "hypotenuse" doesn't need long names.
Rich
I disagree, the effort to make the name longer is minuscule and cost nothing at runtime or compilation. Might as well make it a readable name.
Doug T.
What about single-variable names that correspond to conventions in standard mathematical notation?
dsimcha
Well single letter variables are one of my pet-peeves with standard mathematical notation so I'm against them.
Benjamin Confino
the only thing bad about that is that you're using p*p instead of x*x
Mark
Once knew a consultant who wouldn't use a variable more than two letters long. That way no one else could maintain his code.
PTBNL
PTBNL
hmm, x,y,z,r,a,b,c,d are all commonly used in geometry. Nothing wrong with short-lived single-char vars.
John
+6  A: 

There was a class called "HelperFunc" in one of the projects I have worked on. That class contained only static "helper" methods which had nothing in common - just a place to throw in random code.

korchev
+7  A: 

I used to work with Powerbuilder and people keep naming variables var1, var2, var3, var4 ... etc. We usually had up to var20. It was hell (I resigned :) )

Pablo Fernandez
And of course this was entirely PowerBuilder's fault.
Bernard Dy
+5  A: 

Profanity... I won't type the example.

dacracot
I had two cow-orkers who used to do this. They were very amused with themselves until they had to debug their own work.
Bill the Lizard
Cow-workers? Mooh!
JesperE
Is orking cows illegal in your jurisdiction?
Jeffrey Hantin
A: 
i

I know, we all love using i for loops, but it's pretty much always the worst choice. Be more descriptive!

I hate seeing loops such as:

for ($i = 0; $i < 10; $i++) {
    for ($j = 0; $j < $i; $j++) {
            $k = $j * $i;
    }
}

It isn't readable, and it doesn't help anyone!

Rich Bradshaw
i ... as in iterator?
Jonathan Arkell
i ... as in integer?
palm3D
looks fine to me, except for the dollar-signs
Steven A. Lowe
I can deal with i, j, k stuff. I have a tougher time with temp1, temp2, temp3 or lngI, lngJ or m_I, m_J.
bruceatk
`i` has come to mean `loop-counter`. it's perfectly readable... unless you're using it for something other than iterating over something
Mark
While I totally agree on the use of 'i' as a for-loop var name, it does get a bit awkward when there's nested loops, as illustrated above in the answer. In the above case, 'i' is obviously not *just* a loop counter, more likely this type of thing is dealing with a matrix or table, in which case row/col, x/y/z are more suitable names for the temporary variables. When you get to 'm', STOP! :D
ptomli
TRWTF here is $k. $i and $j are fine
Eric
A: 

Anything that doesn't describe the variable's content.

Leon Tayson
+15  A: 

Anything prefixed with "My". We once hired a junior programmer who came up with such doozies as "MyClass", "MyInterface", and "MyMethod1". It was clear he was copying/pasting from a general tutorial (we later found it online), but couldn't be troubled to modify the sample.

Ben Hoffstein
I agree with this-- I vomit each time I see any class/ method that starts with My..
Ngu Soon Hui
I've seen worse, but yes, "My" is pretty meaningless. At least it's short.
Bernard Dy
MySQL?(what's with the lower character limit on comments, anyway...?)
Anders Sandvig
Equally annoying is Rational Rose's : theRelatedObject autonaming.
chris
:| i like My prefix and if they do use it in tutorial than its design pattern :P
01
+16  A: 
JesusBuysCookies()

Private method in an in-house cookie handling library.

olle
priceless. I'm going to use that right now.
Steve B.
And, of course, it answers the question posed here: http://www.imdb.com/title/tt0939681/
James Curran
I once called a routine that discarded all stored cookie values "TossCookies".
Jeffrey Hantin
+17  A: 

I don't remember the actual collection name, but assMaster was named by my mentor on my last project (and he is a guy who doesn't swear).

foreach(var assMaster in assembly.LinkedAssemblies)
{
   ProcessTypes(assMaster)
}
Jacob
+22  A: 

From the Windows 3.x kernel:

void FAR Bunny_351(void);
Long FAR PASCAL BozosLiveHere(HWND, WORD, WORD, DWORD);
WORD FAR PASCAL PrestoChangoSelector(WORD, WORD);

Bunny_351 is a an internal function called when windows shuts down. It's name was to honor a stuffed bunny that had an unfortunate accident with a paper shredder.

BozosLiveHere, a mysterious function that returns the string "USER: Invalid function called. System state potentially trashed,".

PrestoChangoSelector generates a code selector without validating the parameters so it is quicker than ChangeSelector.

Source: Undocumented Windows

Gamecat
According to Raymond Chen, "BOZOSLIVEHERE was originally the window procedure for the edit control, with the rather nondescript name of EditWndProc". He also explains why these names. Source: http://blogs.msdn.com/oldnewthing/archive/2003/10/15/55296.aspx
CesarB
nice info, thanks.
Gamecat
A: 

Toto

I maintained a project created by French developers and many local variables were named "toto". There were also some "koko", i think it's a derivative from "toto". I still have no idea what it means :)

Constantin
+4  A: 

In our World Series Baseball code for the Sega Genesis, we had a variable put in by an irate programmer whose name I can't quite type in here, but I think you'll get the idea:

int StupidFxxkingFlagThatSegaMakesUsFxxkingHave

Bill James
I'd just like to say, I _loved_ that game.
Matt Grande
+1  A: 

Using our graph-library, with JavaScript support for dynamic manipulation. No documentation provided:

doThatGraphThing( ... );

I laughed a bit, then went to have a talk with the developer, as this was release-code.

roosteronacid
+27  A: 

I have a coworker that routinely uses sentences for method names. For example:

LetsProceedWithHandlingTheErrorFromThatOneMethod()

(oh yeah, he begins lots of method names with "Lets")

Christopher
+1 that's particularly vile.
DarkSquid
The "lets" is silly, but sentences can often make good method names.
finnw
that feels like pair programming even if you didn't
Anurag
+18  A: 

All variable names that "saves" you 2 or 3 keystrokes.

Like bta instead of beta, prmtr instead of parameter etc.

With intellisense you usually only need the first 3 letters anyway so why not use long descriptive names?

Who came up with this crap from the beginning btw? Was it the low-resolution displays that forced you to do this to get all code on one line or maybe language limitations?

I had a boss who used to do this so badly that the names became indecipherable, and of course, he'd act like we were the dumb ones when we couldn't figure out what they mean. If not knowing the meaning "bldSbELmTbl" make me an idiot, then I guess I'm an idiot.
nerdabilly
(he really did name a function tbldSbELmTbl once. Also, I think this goes back to the days where saving memory was really important.
nerdabilly
Kind of ironic you use the acronym "btw" to save you a few keystrokes :)
Will Robertson
Early linkers would only recognize the first 8 letters of an identifier, so they had to be distinctive in that range. Characters after that were pointless.
James Curran
I came across this one a few days ago trying to make a stylesheet for someone. Not only were their class/ID names all mssng_vwls_at_rndm, but they left out classes to save space when they had an ID already. Want to style 5 different nav menus? Type out 5 separate IDs each time.
Ant P.
JeffH
+11  A: 
IsHardwareSoundPlaying_PleaseDontUseThis(). 

Called in at least 50 places in the code base, working perfectly.

yrp
+2  A: 

Anything that uses i, I, l, 1, o, O, or 0.

Dan Udey
As a single letter I presume you mean?
Chris Noe
As non distinguishable letters that would be.
Ralph Rickenbach
Easily solved by using a decent programming font. I like Consolas a lot, each of those characters are distinctly different in my editor.
Adam Lassek
Another vote for Consolas.
Herms
Was that C0nsolas, COns01as or con5O1a5?
micahwittman
O_O?.................
User
+55  A: 

A function to return a parentID of some product

<?php

    function whoIsYourDaddy($id)
    {
        return $this->parentID;
    }

?>
Ólafur Waage
Ah, I see the problem. It should have been: whosYourDaddy($id)
Chris Noe
Or more of the web 2.0 style: whosYrDaddy($id)
Georgi
Yep, everyone knows object pointers are female, so the correct name would be whoIsYourMummy.
Gamecat
Gamecat: You shouldn't objectify women like that.
chris
Don't anthropomorphize computer constructs. They hate that.
Svante
LOL i dropped under the table rolling on the floor
User
Hope you're ok :D
Ólafur Waage
i’m dying from laughing my ass off!! :D :D :D
knittl
Why do you need a function for that?
UpTheCreek
+67  A: 

isHasDeletePrivilege. One tiny step away from canHasDeletePrivilege, leading me to suspect it may have been written by a cat.

Brian Carper
canHazDeleetPrivlij, would be written by a cat.
Bill the Lizard
Geez, making generated boolean accessor functions start with "is" isOneOfMyPetPeevesAboutCodeGenerators().
Knobloch
In Java boolean getters start with "is" so if you're using JSP or similar this property name will allow you to write code like form.hasDeletePrivilege. I suspect that's the reason for this name.
cletus
@knobloch... it's also a Java standard. If you want to work with common frameworks it's kind of required.
John
A: 
iAn
A: 

Worked with a guy in FORTRAN days who named all his variables: AA1, AA2 etc. He didn't beliwve in continuation lines so he wrote:

AA1 = expression

then most often but not always on the next line:

AA1 = AA1 + expression

In C, functions named f(), c(), cc().

One I really liked was a flag named: AtLeastOneAntennaPulseInTheLastTenSeconds.

Regards, Bill Drissel

Bill Drissel
+10  A: 

While not the "worst" name, this one came to mind.

We have a class used to iterate objects called LOOPER. Here's a code fragment:

LOOPER theSuperDooperLooperScooper( drawing );

theSuperDooperLooperScooper.GetSelected ( GET_ONLY );
Carl
+2  A: 

supercalifragilisticexpialidocious -- needless to say, this occurred before we had code reviews.

Kevin
A: 

I think that the worst examples (other than the obviously funny ones) are the non-english ones. You should not defines variables or whatever in a language that few can recognize. You, at least, lose the semantic power of variable naming.

+8  A: 

I came across this method signature which takes full advantage of java case sensitivity.

public void collectOtherProductsData(
    BigDecimal productSeqId, 
    BigDecimal seqId, 
    BigDecimal SeqId)

Now I need to add another sequence id. Any suggestions?

s_t_e_v_e
I would personally favor: s_e_q_i_d
Chris Noe
I would refactor so it takes a parameter object, that would contain all I need.
CheGueVerra
well, there are 32 different case-permutations of seqid, so you should be fine for a while.
Jimmy
SeqID, obviously. :)
Chris
Chris, no, seqID obviously...
jmucchiello
SEQ_ID_but_not_a_constant
raimesh
In case you run out of simple permutations, you can always turn to homophones: seekEyeDee
Chris Noe
Squid. Obviously.
nilamo
I still don't get it we don't love case sensitive variables (for a good reason) but we defend case sensitive languages. wtf != WTF
dr. evil
@fm that is because we want programmers to be consistent when naming variables. If a and A are the same, then some people will start mixing them.
Stephan202
+3  A: 

Back in the COM days, when MS introduced the smart pointer concept, we had fun with our variable names. We used hungarian notation, and therfore would prefix the variable name with "sp" when using a smart pointer. We also used to truncate the name where possible to save column space. So, a generic IUnknown interface pointer would become "Unk".

You can see where this is going. Juvenile variable names that obey conventions for the win!

Code Trawler
+32  A: 
void crawl_into_hole_and_die()
{
    while(1); // let the watchdog get us.
}
Robert
This one is funny ....
CheGueVerra
I usually name that function "panic()". I wonder if one of my former colleagues will post that on here.
finnw
Could somebody explain to me what exact purpose this serves? I just don't get it...
Bobby
Profilers will get crazy at the function.
badp
@Bobby - in embedded devices, there are usually things called "Watchdogs". The Watchdog will reset the processor if it is not kicked within a certain amount of time. So in the main loop (usually) there are instructions to Kick the Watchdog. This usually writes a special value to the Watchdog register. This function has an infinite loop, so the watchdog will reset the processor.
Robert
@bp, @Robert: Thank you!
Bobby
+9  A: 

Some C code to parse a char[7] to get a year for 2-digit sliding window year logic - unfortunately, I did not save it, but it was something like this:

char[7] textbox ;

int one, two, three ;
char[3] temp ;

temp[0] = textbox[0] ;
temp[1] = textbox[1] ;
temp[2] = 0 ;
one = atoi(temp) ;

temp[0] = textbox[2] ;
temp[1] = textbox[3] ;
two = atoi(temp) ;

temp[0] = textbox[4] ;
temp[1] = textbox[5] ;
three = atoi(temp) ;

// And you might think that's bad, but here comes the greatest line in the history of programming:

if ( three > 70 ) { three = three + 1900 }
else { three = three + 2000 }

// I kid you not

This was written by a couple of Clipper programmers who sold the boss on being able to program in C (I guess because it started with the same letter).

Cade Roux
+2  A: 
  • $stmt (PHP / SQL statement member)
  • coi (I did once name a local variable coi - client object invoice - and in Romanian language that would mean "ball" - as in the singular of testicles). I got called in the executive's office for this at that time.
Andrei Rinea
+3  A: 

Some years ago, I came upon some code like this: (translated in C# from the rather scary scripting language that it was originally in)

foreach(DocumentType shakes in GetDocumentTypes())
{
    ProcessDocumentType(shakes);
}

So, why was the variable holding DocumentType objects calls "shakes". After a few months pondering this, I finally hit me. It was because we calls Document Types, "DTs" which is also the common name for the "Delirium tremens" which is also knows as "The shakes"

James Curran
+16  A: 

Some years ago, I came upon some code like this: (translated in C# from the rather scary scripting language that it was originally in) (Yes, one program, two great dumb variable name stories).

char cArnold = '|';
foreach(char c in GetSomeString())
{
     ...
     if (c == cArnold)
       break;
}

So, why is the end-of-data indicator called "Arnold"? --- Because he's the Terminator!

James Curran
LMAO.. that is funny
Anurag
ahnuld! xD rofl
YuriKolovsky
+3  A: 

Function name:

GiveItAWhirl();

followed closely in the code by

GiveItAWhirl2();

These functions just pieced together unrelated data manipulation and UI code.

theprise
These would best be used in a for each loop iterating over actions...
Matthew Brubaker
+7  A: 

We used to work with a guy (he was nominally team lead, although that wasn't really the case) who insisted on the whole team sticking rigidly to his own set of coding standards. One of these was the old faithful of "no line of code shall be greater than 80 characters".

Of course, we took that as a challenge and spent a month or so attempting to create meaningful and descriptive method names that broke that rule all on their own. I forget that name of the actual method thaqt first hit the 81 character golden marker, but it was something like

UploadedObjectValidationParseEmailAddressAndFullNameUsingStandard<companyname>RegularExpressions

Childish, I know, but this was in response to the guy who once rejected some code during code review on the basis that

"The comment on line 96 has too many words that begin with the letter 'P'"

Seriously.

ZombieSheep
He was worried about a P overflow, no doubt.
micahwittman
+17  A: 

One of these days I'm going to find Kerninghan or Ritchie and make them answer to this

//this function takes a character and converts it to an integer
public int atoi(char a){}

atoi? really?

Ryan
ASCII-to-Integer? That doesn't seem so terrible.
Just Some Guy
I'd like to meet the person who named "creat()" in UNIX.
Kristopher Johnson
Ritchie gave us as, cc, ls, cd, ps, dd, df, pw, sh, sz and myriad others .. be happy with the bloated 'atoi' !
Scott Evernden
Isn't there a quote from Ritchie where someone asked him if he could go back and change one thing in Unix what would he change and the answer was adding the e to the end of creat?
jmucchiello
Colin Pickard
Yeah it should be a2i :P
Cameron MacFarland
+2  A: 

I made a Time Clock program for my office. Every time a user clocks in/out the method called is PunchUser().

Ian Jacobs
+31  A: 

"SetGetSet" and "GetGetSet". They were used to manipulate mbGetSet flag, which meant some kind of readiness. Well, it's not that bad. But then I saw something like this:

Obj1->SetGetSet(Obj2->GetGetSet())

Looks like a piece of Morse code.

akalenuk
laughed out loud...
Shivasubramanian A
I've had a co-worker name variables starting with `GetGet` and `SetGet` for similar reasons, but hadn't seen three levels of it.
dan04
+2  A: 

In the old FORTRAN days, we were linking to a vendor library who had no sense of a naming convention, and used simple variables like x any y in the global namespace. Linking to their library was always filled with collisions. We called them and asked them to use a reasonable naming convention or prefix, and their answer was "we don't ever use anything starting with zz, so you guys can just use zz as the first 2 letters!".

As a result all our variables had to start with zz...

Talk about name space pollution.

We eventually dumped that vendor.

Dan Hewett
A: 

I was maintaining a VB6 app years ago, and came across a situation where I needed to create a single text file by combining two existing text files.

Lucky for me, someone had already written this code. But I had to choose from one of the following methods (which after investigation produced the same result with subtle implementation differences):

  • CombineFiles
  • ConcatFiles
  • JoinFiles
Shawn Miller
A: 

I've been working on an old legacy VB6 program and the butt of most jokes is the function called LoadShmulaka

Shmulaka is not a word that I can find in any dictionary and basically it has become a very bad word in our office. It is a word that means nothing containing code that nobody knows what it does.

SomeMiscGuy
+6  A: 

Maybe not 'worst' as it was actually quite descriptive, but a game project had a method:

void removeUnderwear()
MidnightGun
Which game project?
Andrea Francia
why `void`? I've had many happy returns after running that function. Though, it depends on which object it runs on I suppose.
nickf
A: 

Working on a code base originally written in Sweden, I kept running into the same identifier being used over and over for temporary variables. Turns out it was a Swedish cuss word.

Michael Myers
The obvious question: what was the word?
mizipzor
@mizipzor: It started with a "k", I think. (Yeah, that narrows it down a lot.)
Michael Myers
A: 

In a VB4 project I was brought in to refactor, I found a horrible mess of spaghetti code written by a group from the long since absorbed firm of Coopers & Lybrand, where a recursive loop to traverse a tree spanned three procedures and had two control variables DontDoIt and DontDoItAgain!

In another VB4 project I was asked to review, the programmer was a mainframe developer by training and perhaps used to COBOL or Fortran. He wrote a program to perform EDI mapping. All of his variables had names like XY89123, AB891023, etc, and he also left every single control created in the IDE with the default name, so every form was named Form1, Form15, Command1, Command29, etc!!!

Bill
+9  A: 
doit()
{
    // lots of code
}
spotcatbug
redoit(){ doit();}
nilamo
@nilamo hahahaha
YuriKolovsky
A: 

I was once told a story by a lecturer about a student project. The student decided that their code could also double up some kind of a religious story. With variables like Buddha and Enlightened statements became readable as...

if (Buddha == Enlightened) { SetPathsWalked(&paths); }

The lecturer had no idea what was going on in the code.

Derek Smyth
+12  A: 

Some PHP code: A function which returns a reference. You can't just return null; because that's not a reference to anything. The workaround:

function &getUser() {
    if (/* there's some sort of error... */) {
        $aStupidFuckingVariableIHaveToMakeBecausePHPWontLetMeJustReturnNullBecauseThatWouldMakeTooMuchSenseAndWouldBeWayTooEasy = null;
        return $aStupidFuckingVariableIHaveToMakeBecausePHPWontLetMeJustReturnNullBecauseThatWouldMakeTooMuchSenseAndWouldBeWayTooEasy;
    }
}
nickf
LIES!!! In what version of PHP could you not return null? That doesn't sound PHPish at all....
Mark
it's not returning null, it's returning a reference to a variable which is null. note the ampersand in the function name.
nickf
$randomProfanitiesAndPHPBashing = explode(',', $something);do_something_with($randomProfanitiesAndPHPBashing[$i]);
ymv
A: 

It is jarring to have variables with spelling or grammatical errors. e.g.

Object corbaProxie = service.getProxie();

List recordsFindedWithPrivlidge = new ArrayList();

I often find myself wondering if English was their first language or if they are just poor spellers. I am usually more tolerant of people for whom English is a 2nd language, but in either case, thank heaven for Alt-Sft-R in Eclipse!

Michael Easter
(ahem) That's Alt-<i>Shift</i>-R to you, spell-master.
Paul Brinkley
+6  A: 

I once had to port a C application from unix to windows. The specific nature of the application shall remain unnamed, to protect the guilty. Anyways, the guy who wrote it was a professor, and unaccustomed to writing production-quality code. It also happens that English wasn't his first language (though in the country he comes from, the majority of people speak it quite well). Anyways, in a header file named 'Thing.h', he defines the following:

#define I  Any void_me
#define thou  Any void_thee
#define iam(klas)  klas me = (klas) void_me
#define thouart(klas)  klas thee = (klas) void_thee
#define my  me ->
#define thy  thee ->
#define his  him ->
#define our  my methods ->
#define your  thy methods ->

...which he then used to create monstrosities like the following:

void Thing_setName (I, const char *name) {
iam (Thing);
if (name != my name) {   /* Pointer comparison! So that Thing_setName (me, my name) does not fail. */
    Melder_free (my name);
    my name = Melder_wcsdup (name);
    }
    our nameChanged (me);
}

void Thing_overrideClass (I, void *klas) {
iam (Thing);
my methods = (Thing_Table)klas;
if (! ((Thing_Table) klas) -> destroy)
    ((Thing_Table) klas) -> _initialize (klas);
}

I'm so glad he at least put that comment in there; that really clarifies what the hell the code actually is supposed to do. Anyways, the entire project (~60,000 LOC) was written in a similar style -- marco hell, weird names, olde English jargon, etc. Fortunately we were able to throw it out, as we found an OSS library that did the same task, only cleaner and faster.

Nik Reiman
+2  A: 

I wrote an article awhile back about what developers can learn from Forrest Gump, specifically I talked about how things get named a lot. One example I quoted was one from Phil Haack:

Request.TakePostedValuesAndSetPropertiesOfTheObjectWithTheSameNameToThePostedValueUsingReflection(product);

While this wasn't in production in the ASP.Net MVC framework it still is pretty funny. Phil came up with it because people were complaining at the time about the name DeserializeTo().

The complete article is here for anyone that cares.

Keith Elder
A: 

I've seen classes named after their author like JohnDoesModule and JaneBanesClass. Enough said.

Zizzencs
+7  A: 

not the worst class name ever, but very very funny when i first saw it in a previous role.

CHandJob

I was lmfao when i saw this. Apparently it was related to the notion of a worker in a factory doing something by hand instead of automated by machine(ie placing components onto a PCB).

Dave
And now I'm roflmfao too...
Eduardo León
+1  A: 

One guy was pretty angry, so he named all his variable by the names of his family members. After he left, someone had to deal with lots of "string alex", "int john", "DataTable scott", etc..

A: 

Many years back I wrote an April Fool program using ZXSpectrum Basic as a prank on a fellow pupil which had 'TheInfamousMargretDevanzoSubroutine' in it (Ok, so only two other people in the world will get this joke). Needless to say, it has turned up in a few projects since.

Skizz

Skizz
+1  A: 

kill - send signal to a process

Synopsis:

int kill(pid_t pid, int sig);

Do you want kill something or do you want send signal?

In my old MSX BASIC you could delete files with KILL filename.

Andrea Francia
Well... kill just sends a signal anyway (SIGHUP normally (15), or SIGKILL to actually kill it (9)), but good point.
Lucas Jones
+1  A: 

A few years ago I had finnish a program started by an intern. He had created a lot of methods like

void Bla(); 
void Blo(short Bla); 
void Bli(int Bla, double Blo);

These methods were used like this throughout the entire project. A complete mess... Horrible...

Sorskoot
+3  A: 

From the perverse and happily defunct world of Authorware where spaces in variable names was legal:

booBoolMoveOnIsOn True

Laughably, it was a constant, defined as 1

annakata
Allowing spaces in variable names is a whole league of WTF waiting to happen..
pjc50
+1  A: 

I had to fix bugs in an application that had to delete itself after execution.

The function that performed the (indirect) deletion was called:

void Harakiri();
vobject
A: 

For me it was a Fortran Logical called LNOGRAF (7 character limit). It was used to determine if a graphics terminal was available. The software it was used in only checked if the graphics terminal was available, so the source code was full of

IF .NOT. LNOGRAF

What was worse is that at the time that I became involved a lot of the code was also in PL/I and that same logical was called LNOGRAF for consistencies sake. I worked on it for 4 years and I'm not sure if we ever got rid of all the LNOGRAF's.

The application was 3D mission planning software for B-52's and Cruise Missiles. It had the distinction of being name GASCAP (mainly because of the 1979 gas crisis).

GASCAP stands for Graphics Application Software for Cruise missile and Aircraft Planning.

bruceatk
+1  A: 
private void rape(TimFlop victim) {
    if (Math.random() < 0.7) {
        flop.getGameObject().AddFlop(new TimFlop(flop, victim));
    }
}
utdiscant
+1  A: 

Anything mis-spelled which has spread its way through the code thanks to the miracle of intellisense/identifier completion, especially once it surfaces in a public API, which means you then can't correct it without screwing with some customer's software.

raimesh
+2  A: 

I also once worked on a project which defined a C++ enum of values returned from a DB search call and included the value "DB_NOTAGOATATALL". I think it was originally DB_NOTAGOATALL for "Not a 'go' at all", i.e. the search failed utterly, however someone decided that "Not a goat all" was bad English and inserted the missing "at", and it just stuck.

raimesh
A: 

Maybe not the worst, but one of the funnier ones were from a form for defining Table Type Assignment properties (allow table combining, allow smoking, etc)

TableTypeAssCombine

TableTypeAssSmoking

Rob McCready
A: 

I was contracted a long time ago to port and add features to a reasonably complicated legacy application to a new platform. They didn't let me fix any of the obvious existing flaws in functionality.

Another programmer took over parts of the project for a while. And then a bit later I came back to the code he had changed. He'd introduced variables whose names were variations on STUPIDMARK and MARKSANIDIOT.

sigh. Thanks, man. Look, I do the best I can with the restraints I got.

catfood
+65  A: 

At my first programming job, we had a system which would scan images of checks in large batches, use a MICR reader to pull the account and routing number off the check, then match the check to the corresponding account in the database. As you can imagine, some checks are unreadable and can't be paired up with an account. We referred to images without an account as orphans, and our system required all orphans needed to be reconciled by hand and reprocessed. Some methods I remember off the top of my head:

HarvestOrphans - queries the database for orphaned images, pulls images into a grid on the UI.

KillsOrphans - deletes all orphans in the pending deletion queue.

MakeOrphanDirty - method is called when a user modifies an orphan. Sets the "IsDirty" flag on the orphan.

TouchDirtyOrphans - reprocesses orphans modified by the user. First comment in method is // no ! bad touch!

This funny in-joke lasted for 5 years until one of our customers commented on some of our error logs, specifically the OrphanMolestationException recently thrown in the TouchDirtyOrphans method. Its a miracle no one was fired :)

Juliet
+1 for making me LOL
Graham Miller
Just... brilliant.
snake
Wow, that is absolute gold!
Evgeny
hahahaha laughing in tears.
YuriKolovsky
A: 

SQL Variable name

Declare @InfiniteLoopCatcher int

Then it was use like

If InfiniteLoopCatcher = 10000 return 0

hcoohc03
A: 

I remember encountering a variable called 'iMinSecureCode' ostensibly for storing an integer holding the mininum security code. But when I pronounced the variable name out loud, somebody asked me: why are you insecure?

George Jempty
A: 

getIsLocked() or somesuch; it jarred with me in a horrible fashion. Odd names, pop culture references and even long winded drivel I can deal with, but for some reason, this one little method name caused me to die a tiny bit inside.

The rest of the code in question was somewhat...questionable.

Rob
A: 
static int i;  /* file scope */

Someone added a harmless looking for (i = 0; ... ) deep inside a function, assuming that a function this big probably had a local variable called i. It didn't. The compiler didn't complain obviously and the unrelated piece of code that depended on the static variable broke as a result.

sigjuice
This is why you don't use `i` for anything *but* for-loops. If the scope is any larger than that....you need a better/longer variable name >.<
Mark
I completely agree. I never expect to see a global variable called 'i' even in my wildest dreams. This is why this bug was hard to track down.
sigjuice
Assuming that there is a local variable called 'i' is a bad idea. You need to search the function anyway, in case you are already inside a loop that uses 'i' as a control variable. And if you can do that, you can check the declarations at the top.
finnw
A: 
bool etalon;

Near as I could figure from deciphering the code, it means "default" in some other language.

Chris Doggett
etalon in french rather means "reference value"
Eric
@Eric: Good to know. Thanks.
Chris Doggett
A: 

obja,objc,objd,objx,objr,objp... many ex-VB6 programmers in my country like to prefix every object they made with obj. Perhaps that made sense in VB6 but it only reduces readibility in VB.Net.
The problem is that these programmers often are the ones that teach, so the habit is passed to the new generations.

ggf31416
A: 

On a recent Ruby project, someone had added a method to all numeric types to fromat them as currency. You called it like this:

total.to_buxx

Not the worst thing I ever saw, but it gave me a chuckle.

Matt Grande
A: 

Hmmm...

Public Shared Sub RoboMouse()
    Dim MyRobot As Point
    ' ... '
End Sub
Lucas Jones
A: 

There was this really rough migration project I worked on long ago. The specs kept shifting, and the end client hadn't asked for what they wanted or needed, so it was slow going with a lot of rewriting. At one point they brought in this other guy to do further changes to some code I'd already done a lot of work on.

The new guy wasn't aware of the complex and somewhat misguided history of this code, and as you might expect, some of it made me look less than brilliant. That happens when the code is rough to start with, specs are poor, and they absolutely will not let you refactor.

Anyway, a few months later I returned to some of these rough spots to make even more changes. Only to find variables with names like STUPIDMARK and MARKSANIDIOT.

Yeah, thanks dude. Appreciate your support.

catfood
A: 

The use of foo and bar in examples, everywhere, all the time. Because since those words have explicitly no meaning, almost -anything- would be better names for whatever the variables are there for.

Tchalvak
A: 

One that always makes me laugh is kNullObject in the Maya API. However, it's one of those localized jokes so I don't expect anyone that don't speak Swedish to enjoy it.

Laserallan
i just used google translate for this. knull in english is a four letter word starting with f and ending with k
Eric
A: 

Full disclosure: Something I did in my first couple programming classes while learning Pascal:

done := False;
repeat
  { do stuff }
  if end_condition_met then done := True;
until done;

This might be useful if there are several ways to get out of the loop, but I did this even when there was only one end condition. Fortunately, I outgrew that after a while.

Alas, in trying to remember enough Pascal to make this look right, I just found an online example doing the same thing. :-(

PTBNL
+1  A: 

This one was in C# code. Don't ask me what it was supposed to do.

static Func<T, Func<T>> HeavyMetalIsFun<T>(Func<T> fun);
Pavel Minaev
A: 

I had to maintain a file littered with:

int link_state;
int lnk_handle;
int lnk_hdl;
int grp_lnk_index;
int grp_link;
int blk_hdl;
int active_link;
int group_handle;
int group_cfg;
control_block_config* ctrl_block;

No rhyme or reason to whether the name would be abbreviated. What a minefield. The first thing I did was global search & replace each name with the spelled-out version. (Not that big a risk given that the code was a disaster to begin with...)

bstpierre
+1  A: 

I can't believe no one has mentioned HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor yet. (At least it works as a bit of humor as well.)

Michael Madsen
A: 

I did encoutered :

if (!$this->get("justdoit"))
{
    $this->setError(True);
}

One of my colleague had to refactor this code, lost in a 5000 lines long PHP script without single class but full of nested "if". Needingless to say that after 3 months, he rewrote it entirely and we never knew what was that line for.

e-satis
Did you really write "5OOO"? Are you using a typewriter?
Ken
Lol, I did? And don't know why. Funny.
e-satis
+1  A: 

This was made in vb6, i think the code speaks for himself. I called this: "Temporal Coding"

                    Do While Not rstmp.EOF
                        tmp1 = 0:  tmp2 = 0: tmp3 = 0: tmp4 = 0: tmp5 = 0:  tmp6 = 0
                        Call barraProgr(IIf(rstmp.PercentPosition > ProgressBar1.Min, rstmp.PercentPosition, ProgressBar1.Min))
                        ttLinCod = rstmp.Fields("LINCODIGO")
                        tmpAdd = Trim(rstmp.Fields("LINDESCRIPCION")) + " (Cod:" + Trim(Str(ttLinCod)) + ")" + Chr(9)

                        sql = "SELECT Sum(CUOTA.CUOUNIDADES) AS SumaDeCUOUNIDADES, Sum(CUOTA.CUOMONTO) AS SumaDeCUOMONTO"
                        sql = sql + " FROM CUOTA INNER JOIN PRODUCTO ON CUOTA.PROCODIGO = PRODUCTO.PROCODIGO"
                        sql = sql + " WHERE CUOTA.VENCODIGO=" & iddUsuario
                        sql = sql + " AND PRODUCTO.LINCODIGO=" & ttLinCod
                        sql = sql + " AND CUOTA.CUOPERIODO=" & Format(fchDesdeHasta(0), "yyyymm")
                        Set rsCuota = dbMain.OpenRecordset(sql, dbOpenSnapshot)
                        If rsCuota.EOF Or rsCuota.BOF Then
                        Else
                            If Not IsNull(rsCuota.Fields("SumaDeCUOUNIDADES")) Then
                                tmp1 = rsCuota.Fields("SumaDeCUOUNIDADES") '2
                                tmp2 = rsCuota.Fields("SumaDeCUOMONTO") '3
                                mTotalesMSF(0) = mTotalesMSF(0) + tmp1
                                mTotalesMSF(1) = mTotalesMSF(1) + tmp2
                            End If
                        End If
                        tmpAdd = tmpAdd + Format(tmp1, "###,##0") + Chr(9)
                        tmpAdd = tmpAdd + Format(tmp2, "###,##0") + Chr(9)

                        sql = "SELECT Sum(HISTORIC.HISCANTORDENADA) AS SumaDeHISCANTORDENADA, Sum(HISTORIC.HISMONTO) AS SumaDeHISMONTO"
                        sql = sql + " FROM ((VENCLI INNER JOIN HISTORIC ON VENCLI.CLICODIGO = HISTORIC.CLICODIGO) INNER JOIN VENLIN ON VENCLI.VENCODIGO = VENLIN.VENCODIGO) INNER JOIN PRODUCTO ON (PRODUCTO.LINCODIGO = VENLIN.LINCODIGO) AND (HISTORIC.PROCODIGO = PRODUCTO.PROCODIGO)"
                        sql = sql + " WHERE VENCLI.VENCODIGO=" & iddUsuario
                        sql = sql + " AND VENLIN.LINCODIGO=" & ttLinCod
                        sql = sql + " AND HISTORIC.HISPERIODOFACT=" & Format(fchDesdeHasta(0), "yyyymm")
                        Set rsHist = dbMain.OpenRecordset(sql, dbOpenSnapshot)
                        If rsHist.EOF Or rsHist.BOF Then
                        Else
                            If Not IsNull(rsHist.Fields("SumaDeHISCANTORDENADA")) Then
                                tmp3 = rsHist.Fields("SumaDeHISCANTORDENADA") '4
                                tmp4 = rsHist.Fields("SumaDeHISMONTO") '5
                                mTotalesMSF(2) = mTotalesMSF(2) + tmp3
                                mTotalesMSF(3) = mTotalesMSF(3) + tmp4
                            End If
                        End If
                        tmpAdd = tmpAdd + Format(tmp3, "###,##0") + Chr(9)
                        tmpAdd = tmpAdd + Format(tmp4, "###,##0") + Chr(9)

                        If Month(CDate(fchDesdeHasta(0))) <> Month(Now) Then GoTo noCalcPed

                        sql = "SELECT Sum(ITEM.ITECANTAENTREGAR) AS SumaDeITECANTAENTREGAR, Sum([ITEM]![ITECANTAENTREGAR]*[ITEM]![ITEPRECIOUNIT]) AS PrecioTotal"
                        sql = sql + " FROM (VENLIN INNER JOIN (((ITEM INNER JOIN PEDIDO ON ITEM.PEDCODIGO = PEDIDO.PEDCODIGO) INNER JOIN ESTADO ON ITEM.ESTCODIGO = ESTADO.ESTCODIGO) INNER JOIN VENCLI ON PEDIDO.CLICODIGO = VENCLI.CLICODIGO) ON VENLIN.VENCODIGO = VENCLI.VENCODIGO) INNER JOIN PRODUCTO ON (PRODUCTO.LINCODIGO = VENLIN.LINCODIGO) AND (ITEM.PROCODIGO = PRODUCTO.PROCODIGO)"
                        sql = sql + " WHERE ESTADO.ESTACTIVO=1 AND VENCLI.VENCODIGO=" & iddUsuario
                        sql = sql + " AND VENLIN.LINCODIGO=" & ttLinCod
                        Set rsPed = dbMain.OpenRecordset(sql, dbOpenSnapshot)
                        If rsPed.EOF Or rsPed.BOF Then
                        Else
                            If Not IsNull(rsPed.Fields("SumaDeITECANTAENTREGAR")) Then
                                tmp5 = rsPed.Fields("SumaDeITECANTAENTREGAR") '4
                                tmp6 = rsPed.Fields("PrecioTotal") '5
                                mTotalesMSF(4) = mTotalesMSF(4) + tmp5
                                mTotalesMSF(5) = mTotalesMSF(5) + tmp6
                            End If
                        End If
noCalcPed:
                        tmpAdd = tmpAdd + Format(tmp5, "###,##0") + Chr(9)
                        tmpAdd = tmpAdd + Format(tmp6, "###,##0") + Chr(9)
                        tmpAdd = tmpAdd + Format(tmp3 + tmp5, "###,##0") + Chr(9)
                        tmpAdd = tmpAdd + Format(tmp4 + tmp6, "###,##0") + Chr(9)
                        mTotalesMSF(6) = mTotalesMSF(6) + tmp6 + tmp4
                        If tmp1 = 0 Then
                            tmpCero = 100
                        Else
                            If tmp3 + tmp5 = 0 Then
                                tmpCero = 0
                            Else
                                tmpCero = ((tmp3 + tmp5) / tmp1) * 100
                            End If
                        End If
                        tmpAdd = tmpAdd + Format(tmp3 + tmp5 - tmp1, "#,##0") + Chr(9)
                        tmpAdd = tmpAdd + Format(tmpCero, "#,##0") + "%" + Chr(9)
                        If tmp2 = 0 Then
                            tmpCero = 100
                        Else
                            If tmp4 + tmp6 = 0 Then
                                tmpCero = 0
                            Else
                                tmpCero = ((tmp4 + tmp6) / tmp2) * 100
                            End If
                        End If
                        tmpAdd = tmpAdd + Format(tmp4 + tmp6 - tmp2, "#,##0") + Chr(9)
                        tmpAdd = tmpAdd + Format(tmpCero, "#,##0") + "%"
                        mTotalesMSF(7) = mTotalesMSF(7) + tmp4 + tmp6 - tmp2
                        If tmp1 + tmp2 + tmp3 + tmp4 + tmp5 + tmp6 <> 0 Then msfConsulta.AddItem tmpAdd
                        rstmp.MoveNext
                    Loop
Burnsys
finnw
+1  A: 

An ex-coworker of mine decided that he didn't like the usual way of appending strings in PHP, so created his two functions: StringAppend and dneppAGnirts. Both functions took two arguments, and returned a concatenation, except that the latter would concatenate the two parameters in reverse order.

Daniel Vandersluis
+1  A: 

I once wrote some machine path optimization code in FORTRAN, where the underlying data structure was a huge array of points (punch hits). In order to optimize the points, I needed to track the start and end of a given range of hits. I did so with the following variables:

ishit
iehit

For the year or so that I worked in and around that code, I always read the variables as "i start hit" and "i end hit". It wasn't until much later, when the code was less familiar to me, that I saw "ishit" for what it really was... ;^)

Jeff Godfrey
A: 

I honestly encountered complete applications written almost entirely with generic method/variable names...

Variables:

  • MyA
  • MyB
  • Txt122

Functions:

  • DoThis
  • DoFunction
Mayo
+2  A: 

I once worked on a code base that had the most generic method call I think I've ever seen.

public void execute(Object data);

Unsurprisingly, I can't remember what it was supposed to do.

Darren Greaves
You mean like how thread/app classes in standard libraries often have run()/execute() methods?
John
A: 

Mine would have to be:

int cnt

Very easy to say what that was....with a vowel dropped, but I strangely enough I get into the habit of doing that in writing loops like this

for (int cnt = 0; cnt < len; cnt++){ .... }

Incidentally, I am not alone on this, a perl programmer once typed in by mistake on the perl variable in front of a crowd, $c*nt by accident....instead of $count....

Best regards, Tom.

tommieb75
A: 

f($x), ff($x), ff2($x), fff($x, $x2), ffg($f), fgg($f, $z), ...

And this beauties usually reproduce by copy-paste

ymv
+1  A: 

I've read through some of the other answers but none of them seemed to compare to what I've had to work with. Ever wonder to youself if there's anything worse than just naming your variables data1, data2, data3, etc? Try repeating the last letter of your previous variable!

Warning: I just pulled this straight out of the source code to a very critical internal VB6 app I've been tasked with debugging/maintaining. This naming convention is probably proprietary!

Dim tDif As String ' difference in time tBS - tIVM
Dim tDiff As String ' result of tA1Scr - t1RPB
Dim tDifff As String ' result of SubTimes(tA1Scr, tCV1)
Dim tDiffff As String 'result of SubTimes(tA2Scr, tCV3)

I guess it wouldn't be the worst I'd ever seen except that it lied in the middle of the following code block (comments censored only where noted):

  Function Results16()
    Dim ibs As Integer
    Dim ihs As Integer
    Dim tCV2 As String 'time of censored movement
    Dim tCV4 As String 'time of censored movement
    Dim tCV1 As String 'time of censored movement
    Dim tCV3 As String 'time of censored movement
    Dim tIVM As String ' time of censored movement
    Dim isec As mSec ' object to handle time
    Dim rng1RPB As Range ' value/row of censored open
    Dim rng2RPB As Range ' value/row of censored open
    Dim ro1 As Integer ' row
    Dim ro2 As Integer ' row
    Dim t1RPB As String 'time of censored
    Dim t2RPB As String 'time of censored
    Dim tBS As String 'time of combined censored signal
    Dim i As Integer ' wrtie tool for row count
    Dim rngA1Scr As Range ' half scr value/row
    Dim rngA2Scr As Range ' other half scr value/rowf
    Dim tA1Scr As String ' time of half scr A1
    Dim tA2Scr As String ' time of half scr A2
    Dim ros As Integer ' row for scr
    Dim tDif As String ' difference in time tBS - tIVM
    Dim tDiff As String ' result of tA1Scr - t1RPB
    Dim tDifff As String ' result of SubTimes(tA1Scr, tCV1)
    Dim tDiffff As String 'result of SubTimes(tA2Scr, tCV3)
    Dim rng1RPBFlag As Boolean
    Dim rng2RPBFlag As Boolean
    Dim stra As String 'used for printout
    Dim strb As String 'used for printout
    Dim strc As String 'used for printout
    Dim strd As String 'used for printout
    Dim arr(1 To 2)  As String
    Dim r As Integer ' loop through array

    'everything that the results have in common is done in Analyze data
    Call AnalyzeData
    i = 8 

etc etc etc... take note of the fact that Function Results16() indicates that there are AT LEAST 15 other similar functions. Further, please note that neither Results16 nor AnalyzeData take any parameters or have any possible return values--despite being declared as Functions.

nvuono
A: 

I once encountered a set of methods that looked like this:

public static void IncrementByOne(ref int integer)
{
    integer++;
}

public static void IncrementByTwo(ref int integer)
{
    integer++;
    integer++;
}

public static void IncrementByNone(ref int integer)
{
}

I guess they served to see if the ++ operator was really working.

Thomas
A: 

I once implemented a pool of worker processes where a ProcessPool object managed a number of PoolProcess objects. The names are technically correct, but try explaining the design (even to yourself!)

Dawie Strauss
+1  A: 
public void la_applete_est_démarrage_ici() {

}

from a coworker which was french and always used method names with french special characters like ç, é, à, etc.

He also invented this boolean ;)

String OuiOuNon = "Non";
if (OuiOuNon == "Non") {

}
Roflcoptr