Representative Line: Without Directions

This post was originally published on this site

The Daily WTF

Adam S sends us a representative line which represents a mystery. It’s a simple enough Java statement:

private static final Integer[] DIRECTIONS = { 0, 1, 2, 3, 5, 6, 7, 8 };

There is no documentation, no commentary, no explanation of what, exactly, this is supposed to represent. Why did the developer choose to use Integer and not the int primitive type? Why is this just a sequence of numbers in order? Why is 4 missing from the sequence?

The only clue we have is to look at how this particular constant is used, but that is, sadly, no extra help: “DIRECTIONS.length“`. It leaves us with another question: why not just have a constant integer value?

The fact that there are eight entries is tantalizingly reasonable: North, North-East, East, etc. Except we include 0 and 8, but exclude 4, which doesn’t make sense. Did the original developer

To read the full article click on the 'post' link at the top.