Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
Trivial
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: 2.1
-
Component/s: DSL for Business Domain
-
Labels:None
-
Number of attachments :
Description
During the demo I noticed two places that would benefit from adding a annotation during generation. I'm sure this will be very easy to add, but could make the life of some future programmers better.
The first annotation I would like to see is in the domain class, the protected empty constructor. Its impossible to make it private (for Hibernate proxy) but we would be possible to add a @Deprecated annotation. If somebody accidently uses the constructor it will be clear that it should not be used.
The second annotation could be placed on the public constructor: @Override.
This annotation guides the IDE to check if the method is really a method that overrides something from a parent. Thus if you change the method signature, and it doesn't correspond with the parent anymore, you'll get a warning. (Otherwise you've made your own constructor instead of overriding).
(more elaborate description: http://techpolesen.blogspot.com/2007/11/why-override-annotation-is-cool.html)
Maybe the @Override annotation could be used elsewhere in the code too.
Jos Warmer [31/okt/08 02:30 PM]
I tried to add @override to methods that need to implement a method from an implemenetd interface. @Override only seems to check whether it overrides an existing method. I cannot find an annotation to state that a method must implement an interface method. IS there such a thing ?
Roy van Rijn [15/jan/09 05:57 PM]
Ah no, the @Override only works when overriding a class, and this isn't done in mod4j currently (only by the user on the extension points).
Instead they should have created an @Implements annotation, but for some unknown reason they didn't, the community has asked for it though:
http://forums.java.net/jive/message.jspa?messageID=31654
http://forums.java.net/jive/thread.jspa?forumID=23&threadID=1470
I do think that would be a good addition... but since it doesn't exist yet..
As of jdk 6 you can use @Overide for methods that implement interface methods.