Sunday, June 30, 2013

Hodor qualification

In the world of creative programming jargon, we already knew about Yoda conditions (“if three the size is”):

if (3 == size) {
  ...
}

And about Pokémon exception handling (“gotta catch 'em all!”):

try {
  ...
}
catch (Exception ex) {
  ...
}

Now I recently ran into a new antipattern, and decided to name it Hodor qualification after the character from Game of Thrones who can only say his own name.

Hodor qualification is to needlessly prefix calls to static methods by their class name, even from within the same class:

class Hodor {

  private static int foo(int x) { ... }

  private static void bar() {
    return Hodor.foo(1) + Hodor.foo(2) + Hodor.foo(3);
  }

}

Hodor!