Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the Google Annotations Gallery useful in production code?

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?

like image 613
cafe Avatar asked Apr 01 '10 09:04

cafe


2 Answers

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.

like image 109
Bozho Avatar answered Oct 26 '22 07:10

Bozho


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.

like image 26
Epaga Avatar answered Oct 26 '22 07:10

Epaga