开发者

Is the Google Annotations Gallery useful in production code?

开发者 https://www.devze.com 2022-12-25 02:48 出处:网络
I could actually see a use for the Google Annotations Gallery in real code: Stumble across code that somehow works

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?


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.


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.


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.


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.


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...

0

精彩评论

暂无评论...
验证码 换一张
取 消