Yes Virginia, WTFs are real

The Daily WTF is not fiction, people really do write stupid code. This is actual, production Java code that I now have to support.
public static final int ZERO = 0;<BR/> public static final int ONE = 1;<BR/> public static final int TWO = 2;<BR/> public static final int THREE = 3;<BR/> public static final int FOUR = 4;<BR/> public static final int FIVE = 5;<BR/> public static final int SIX = 6;<BR/> public static final int SEVEN = 7;<BR/> public static final int EIGHT = 8;<BR/> public static final int NINE = 9;<BR/>
Weep for me.

Bonus points if this was written for a post 1.5 JDK where you have enums

Consider yourself lucky, the values are correct. I found one piece of code in our code base where Byte1 was set to 1, byte2 was set to 2 up to byte 4, no byte5 to 8, byte9 was set to 10 and byte10 was set to 11.
And sadly those numbers happened to be correct (in that it did what it was documented to do)

This is useful when you code using voice recognition software, and the software insists on inserting the written numbers instead of the numerals.

@warmachine said:
The Daily WTF is not fiction, people really do write stupid code. This is actual, production Java code that I now have to support.
public static final int ZERO = 0;<br> public static final int ONE = 1;<br> public static final int TWO = 2;<br> public static final int THREE = 3;<br> public static final int FOUR = 4;<br> public static final int FIVE = 5;<br> public static final int SIX = 6;<br> public static final int SEVEN = 7;<br> public static final int EIGHT = 8;<br> public static final int NINE = 9;<br>
Weep for me.
You are now dutybound to change these values, release the code to production, and see what breaks.

But magic numbers are bad!

@geocities said:
This is useful when you code using voice recognition software, and the software insists on inserting the written numbers instead of the numerals.
What?

@derula said:
@geocities said:
This is useful when you code using voice recognition software, and the software insists on inserting the written numbers instead of the numerals.
What?
You mean you don't program using voice recognition? It really saves your wrists from carpal tunnel syndrome and at first you feel like you're in an episode of Star Trek, and you get good practice pronouncing some phrases you never get to say in everyday speech, such as ampersand and left curly brace.
Get with the times, it's 2011! Keyboards are so oldschool.

You forgot a few:
public static final int NEGATIVE_ZERO = ZERO  ZERO;
public static final int I_SQUARED = ZERO  ONE;
public static final int BIBLICAL_PI = THREE;
public static final int FORTY_TWO = SIX * NINE;
public static final int GENERAL_TSOS_CHICKEN = SIX * (NINE + ONE) + NINE;

@geocities said:
This is useful when you code using voice recognition software, and the software insists on inserting the written numbers instead of the numerals.
No. It's not.

TEN = Integer.Parse(ONE.ToString() & ZERO.ToString())
I think I now have an understanding of what whiskey is for.

@Lorne Kates said:
TEN = Integer.Parse(ONE.ToString() & ZERO.ToString())
public static final int ZERO_X_TEN = TEN + SIX;

public static final int JAVASCRIPT_TEN = EIGHT;

@ekolis said:
public static final int NEGATIVE_ZERO = ZERO  ZERO;
That's not right. A number minus itself is zero. It should be:
public static final int NEGATIVE_ZERO = ZERO  ( ZERO * 2 );

No, negative zero is clearly zero minus zero, because "negative X" is defined as zero minus X!
Though I suppose if your definition and my definition were both valid, then you could factor out a zero or something, and prove that one equals two...

@blakeyrat said:
@ekolis said:
Holy shit, a blakeyrat joke! I'm going to get this bronzed right now!public static final int NEGATIVE_ZERO = ZERO  ZERO;
That's not right. A number minus itself is zero. It should be:public static final int NEGATIVE_ZERO = ZERO  ( ZERO * 2 );

How is this a WTF? When your job is outsourced, it'll be easier to refactor those numbers into a more appropriate, local language. That's simply incredible foresight.

@ekolis said:
Let's try it!No, negative zero is clearly zero minus zero, because "negative X" is defined as zero minus X!
Though I suppose if your definition and my definition were both valid, then you could factor out a zero or something, and prove that one equals two...
ZEROZERO = negative zero
ZERO(2*ZERO) = negative ZERO
ZEROZERO = ZERO(2*ZERO)
subtract a zero from both sides
ZERO = 2*ZERO
divide by negative ZERO
1 = 2
!!!!!

@COctothorpe said:
Holy shit, a blakeyrat joke! I'm going to get this bronzed right now!
I make jokes all the time. You guys just have terrible senses of humor.

@Sutherlands said:
divide by negative ZERO
There's your reason why you don't usually allow to divide by zero. If you do, it follows that 1=2 which implies that all numbers are the same. You can still use that model, but everything based on it will be inherently trivial.

@Power Troll said:
How is this a WTF? When your job is outsourced, it'll be easier to refactor those numbers into a more appropriate, local language. That's simply incredible foresight.
This may not be that far from the truth. It was written by an Indian immigrant who probably did previously work on outsourced projects.


@derula said:
@Sutherlands said:
NSISdivide by negative ZERO
There's your reason why you don't usually allow to divide by zero. If you do, it follows that 1=2 which implies that all numbers are the same. You can still use that model, but everything based on it will be inherently trivial.

@Sutherlands said:
Nullsoft Scriptable Install System?@derula said:
@Sutherlands said:
divide by negative ZERO
There's your reason why you don't usually allow to divide by zero. If you do, it follows that 1=2 which implies that all numbers are the same. You can still use that model, but everything based on it will be inherently trivial.NSIS
Are you sure you didn't mean 'Nullity'?

@ekolis said:
public static final int BIBLICAL_PI = THREE;
I know what you're trying to say, but the scripture in question is not trying to define the value of PI.

@ekolis said:
public static final int BIBLICAL_PI = THREE;
I know of an engineering professor who, in order to simplify doing the math by hand, instructed his class to use pi=3.All his answer keys assumed this fact.

@COctothorpe said:
@blakeyrat said:
@ekolis said:
Holy shit, a blakeyrat joke I actually get! I'm going to get this bronzed right now!public static final int NEGATIVE_ZERO = ZERO  ZERO;
That's not right. A number minus itself is zero. It should be:public static final int NEGATIVE_ZERO = ZERO  ( ZERO * 2 );
FTFY

@serguey123 said:
FTFM@COctothorpe said:
FTFY@blakeyrat said:
@ekolis said:
Holy shit, a blakeyrat joke I actually read! I'm going to get this bronzed right now!public static final int NEGATIVE_ZERO = ZERO  ZERO;
That's not right. A number minus itself is zero. It should be:public static final int NEGATIVE_ZERO = ZERO  ( ZERO * 2 );

@DaveK said:
Not Sure If Serious.@Sutherlands said:
@derula said:
@Sutherlands said:
divide by negative ZERO
There's your reason why you don't usually allow to divide by zero. If you do, it follows that 1=2 which implies that all numbers are the same. You can still use that model, but everything based on it will be inherently trivial.NSIS
Are you sure you didn't mean 'Nullity'?

@Sutherlands said:
@DaveK said:
Not Sure If Serious.@Sutherlands said:
@derula said:
@Sutherlands said:
divide by negative ZERO
There's your reason why you don't usually allow to divide by zero. If you do, it follows that 1=2 which implies that all numbers are the same. You can still use that model, but everything based on it will be inherently trivial.NSIS
Are you sure you didn't mean 'Nullity'?
He's not being serious. He's making a joke at your expense.
And what the hell does NSIS mean?

@Lorne Kates said:
@Sutherlands said:
@DaveK said:
Not Sure If Serious.@Sutherlands said:
@derula said:
@Sutherlands said:
divide by negative ZERO
There's your reason why you don't usually allow to divide by zero. If you do, it follows that 1=2 which implies that all numbers are the same. You can still use that model, but everything based on it will be inherently trivial.NSIS
Are you sure you didn't mean 'Nullity'?
He's not being serious. He's making a joke at your expense.
And what the hell does NSIS mean?
Yeah, seriously. Tell us already!

Naval Shipline Investigative Service. It's a poor spinoff of NCIS

@Sutherlands said:
Naval Shipline Investigative Service. It's a poor spinoff of NCIS
Ah, now it makes sense. Thanks for clarification.