Article 5WYYK CodeSOD: Constantly Sinister

CodeSOD: Constantly Sinister

by
Remy Porter
from The Daily WTF on (#5WYYK)

Cat has some Java code which handles text layout. Now, someone writing the code didn't understand the idea of enumerated types, so every constant is a string.

That's a nuisance, but not a terrible problem. Of course, with Java's String handling, you also run into the fact that == will frequently work, because Java tries to reuse String instances, but it won't always work, and thus equals exists.

So this code didn't actually work:

if (alignment == LEFT_ALIGN) { return RIGHT_ALIGN;} else if (alignment == RIGHT_ALIGN) { return LEFT_ALIGN;} else { return CENTER_ALIGN;}

But even if it did, the only thing I can think when I look at this code is: "No, your other left!"

otter-icon.png [Advertisement] Otter - Provision your servers automatically without ever needing to log-in to a command prompt. Get started today! TheDailyWtf?d=yIl2AUoC8zA
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