views:

314

answers:

5

I could actually see a use for the Google Annotations Gallery in real code:

Stumble across code that somehow works beyond all reason? Life's short. Mark it with @Magic and move on:

@Magic
public static int negate(int n) {
  return new Byte((byte) 0xFF).hashCode()
      / (int) (short) '\uFFFF' * ~0
      * Character.digit ('0', 0) * n
      * (Integer.MAX_VALUE * 2 + 1)
      / (Byte.MIN_VALUE >> 7) * (~1 | 1);
}

This is a serious question. Could this be used in an actual code review?

+1  A: 

Quite. Well, not all of them, but many could be substitutes for longer comments. That holds true for not too many of these annotations, but some (as in your example) could be handy.

It may be said that these annotations present the most common comments in a shorter and perhaps more readable way.

You can later process them, and add tresholds for, say, the number of @Magic annotations. If a project becomes too "magic", measures should be taken.

Bozho
A: 

FYI, Sonar seems to now include a better revision plugin.

Anyway, were you not to guess, i think the short project name is clear enough about this project's intentions : gag the annotations for what they can become when left free : an equivalent to the oh-so-y2k XML hell.

Riduidel
A: 

It would be easier to use comments with a key such as "MAGIC", then work with those. Hudson and Eclipse and other tools can count or mark those occurrences.

Epaga
A: 

I can definitely see how the @CarbonFootprint would fit into several client's CSR policies, and the @WTF("comment") annotation would be really handy when you're working on a new project where you're not sure whether a certain piece of code actually is needed to work around some crazy bug/corner-condition or if it's just random, left-over crap that no one knew how to write better at the time.

gustafc
A: 

I guess some people may have missed the acronym and the date of the that Google Annotation Gallery (GAG) on April 1st... or maybe in some countries it's not a national day for jokes, or gags...

Eric Liprandi