Article 6GGVF CodeSOD: Constant Adventure

CodeSOD: Constant Adventure

by
Remy Porter
from The Daily WTF on (#6GGVF)

We know that June 7th, 2006 was a long day for Jonas, Rusty's long-ago predecessor. We know that, because Jonas made a big commit that day. It was the day someone told him to stop using magic numbers and switch to named constants.

 public static final float FLOAT_0NE_HUNDRED_FIFTY = 150.0f; public static final float FLOAT_EIGHT = 8.0f; public static final float FLOAT_EIGHTY_FIVE_HUNDREDTH = 0.85f; public static final float FLOAT_EIGHT_HUNDREDTH = 0.08f; public static final float FLOAT_EIGHT_HUNDRED_SIX = 806.0f; public static final float FLOAT_TEN_HUNDREDTH = 0.10f; public static final float FLOAT_ELEVEN = 11.0f; public static final float FLOAT_ELEVEN_HUNDREDTH = 0.11f; public static final float FLOAT_FIFTEEN = 15.0f; public static final float FLOAT_FIFTY = 50.0f; public static final float FLOAT_FIFTY_NINE_HUNDREDTH = 0.59f; public static final float FLOAT_FIVE = 5.0f; public static final float FLOAT_FIVE_HUNDRED = 500.0f; public static final float FLOAT_FIVE_HUNDRED_SIXTY = 560.0f; public static final float FLOAT_FIVE_TENTH = 0.5f; public static final float FLOAT_FIVE_THOUSANDTH = 0.005f; public static final float FLOAT_FORTY = 40.0f; public static final float FLOAT_FOURTEEN_HUNDREDTH = 0.14f; public static final float FLOAT_FOUR_HUNDRED_EIGHTY = 480.0f; public static final float FLOAT_FOUR_HUNDRED_NINETY = 490.0f; public static final float FLOAT_FOUR_TENTH = 0.4f; public static final float FLOAT_NINE = 9.0f; public static final float FLOAT_NINETY = 90.0f; public static final float FLOAT_NINETY_EIGHT_HUNDREDTH = 0.98f; public static final float FLOAT_NINETY_NINE_HUNDREDTH = 0.99f; public static final float FLOAT_NINE_HUNDREDTH = 0.09f; public static final float FLOAT_ONE_DOT_TWO_TENTH = 1.2f; public static final float FLOAT_ONE_HUNDRED = 100.0f; public static final float FLOAT_ONE_HUNDREDTH = 0.01f; public static final float FLOAT_ONE_HUNDRED_NINETY_FIVE = 195.0f; public static final float FLOAT_ONE_TENTH = 0.1f; public static final float FLOAT_SEVENTY = 70.0f; public static final float FLOAT_SEVEN_HUNDREDTH = 0.07f; public static final float FLOAT_SIX_HUNDREDTH = 0.06f; public static final float FLOAT_SIX = 6.0f; public static final float FLOAT_SIXTEEN = 16.0f; public static final float FLOAT_TEN = 10.0f; public static final float FLOAT_THIRTY = 30.0f; public static final float FLOAT_THREE_HUNDRED = 300.0f; public static final float FLOAT_THREE_TENTH = 0.3f; public static final float FLOAT_TWELVE = 12.0f; public static final float FLOAT_TWENTY = 20.0f; public static final float FLOAT_TWENTY_FIVE = 25.0f; public static final float FLOAT_TWENTY_FIVE_THOUSANDTH = 0.0025f; public static final float FLOAT_TWO = 2.0f; public static final float FLOAT_TWO_HUNDREDTH = 0.02f; public static final float FLOAT_TWO_TENTH = 0.2f; public static final int INT_EIGHT = 8; public static final int INT_ELEVEN = 11; public static final int INT_FIFTEEN = 15; public static final int INT_FIFTY = 50; public static final int INT_FIVE = 5; public static final int INT_FORTY = 40; public static final int INT_FOUR = 4; public static final int INT_FOURTEEN = 14; public static final int INT_NINE = 9; public static final int INT_NINETEEN_HUNDRED = 1900; public static final int INT_ONE_HUNDRED = 100; public static final int INT_ONE_HUNDRED_FIFTY_SEVEN = 157; public static final int INT_ONE_THOUSAND = 1000; public static final int INT_ONE_THOUSAND_EIGHT = 1008; public static final int INT_ONE_THOUSAND_ELEVEN = 1011; public static final int INT_ONE_THOUSAND_FIVE = 1005; public static final int INT_ONE_THOUSAND_FOUR = 1004; public static final int INT_ONE_THOUSAND_NINE = 1009; public static final int INT_ONE_THOUSAND_SEVEN = 1007; public static final int INT_ONE_THOUSAND_SIX = 1006; public static final int INT_ONE_THOUSAND_THIRTEEN = 1013; public static final int INT_ONE_THOUSAND_THIRTY_FIVE = 1035; public static final int INT_ONE_THOUSAND_THIRTY_FOUR = 1034; public static final int INT_ONE_THOUSAND_THREE = 1003; public static final int INT_ONE_THOUSAND_TWELVE = 1012; public static final int INT_ONE_THOUSAND_TWO = 1002; public static final int INT_SEVEN = 7; public static final int INT_SIX = 6; public static final int INT_SIXTEEN = 16; public static final int INT_SIXTY_THREE = 63; public static final int INT_TEN = 10; public static final int INT_THIRTEEN = 13; public static final int INT_THIRTY = 30; public static final int INT_THIRTY_EIGHT = 38; public static final int INT_THIRTY_ONE = 31; public static final int INT_TWENTY_FIVE = 25; public static final int INT_THREE = 3; public static final int INT_THREE_HUNDRED_SIXTY_FIVE = 365; public static final int INT_TWELVE = 12; public static final int INT_TWENTY = 20; public static final int INT_TWENTY_FOUR = 24; public static final int INT_TWO = 2; public static final int INT_TWO_HUNDRED = 200; public static final int INT_TWO_HUNDRED_SEVENTY = 270; public static final long LONG_ONE = 1L; public static final long LONG_SEVEN = 7L; public static final long LONG_TWO = 2L;

It was indeed a LONG_ONE for Jonas. But at least he didn't need to float "0ne" hundred and fifty constants, just a little less than INT_ONE_HUNDRED.

otter-icon.png [Advertisement] Otter - Provision your servers automatically without ever needing to log-in to a command prompt. Get started today!
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments