2

Does anybody have some kind of "code style" annotations in the project, ex: @OverEngineered for over-complexed code or @Duplicated... etc.

Ideally I'd subclass @Deprecated for that (@OverEngineered extends @Deprecated) to get the IDE highlight it, but java annotations are not inherited.

So I wonder if there is some workaround to get the IDE to highlight such code-style custom annotations as deprecated? Or is this the wrong way or wrong task in general?

Community
  • 1
  • 1
yetanothercoder
  • 1,689
  • 4
  • 21
  • 43

3 Answers3

2

You could write a family of these annotations, and then use them alongside @Deprecated. The latter gets you the warnings, the former supply the details to human readers. You could write a Checkstyle rule to require that every deprecated thing has an explanatory annotation, and/or that every explanation accompanies a deprecation.

Rather than writing several annotations, though, i'd write one, which takes an explanatory label as a parameter. I'd call it @BecauseItIs. So:

@Deprecated @BecauseItIs("overengineered")
public void calculateSumOfTwoIntegersUsingSurfaceIntegrals(int a, int b) {
Tom Anderson
  • 46,189
  • 17
  • 92
  • 133
1

The workaround would be implemented with a plugin you develop for Eclipse. I would say, however, nothing is more semantically as a good written comment in the code.

After all it depends on the purpose. But I think a good comment is better than a plugin which anyone has to install.

Konrad Reiche
  • 27,743
  • 15
  • 106
  • 143
1

It's not clear to me if you have another goal besides calling attention to the spot in the IDE. You mention @Deprecated which also shows up in the Javadoc, IDE documentation popups, and compiler output.

For simply the IDE highlighting without the other possibilities, you could leverage the FIXME / TODO sorts of comment tags that most IDEs support (at least those I've used). Just add your own tags for OVERENGINEERED: this is too ... etc.

Eclipse allows you to also specify if you want case matched, so it could be OverEngineered:

Stephen P
  • 14,422
  • 2
  • 43
  • 67