Re: Preventing HAJOs
"Lars Kühne" <[email protected]>
| Newsgroups | gmane.comp.java.audit.checkstyle.user |
|---|---|
| Message-ID | <[email protected]> |
Mike, yes, such a check should be pretty easy to write. The only slightly complicated part would be the import resolution to figure out the fully qualified name of an annotation. You could probably take a peek at the UnusedImports check sources in the checkstyle distribution to figure that out. Another idea that would be even easier to implement than the whitelist approach: Limit - the maximum number of annotations in a class divided by the number of method definitions + field definitions + 1. Some value around 2 or 3 should be a good default. - the maximum number of annotations per method/field/class. Probably something like 4 would be a good default This approach is completely straightforward to implement and would also be much easier to configure, no need for a project specific whitelist definition. Cheers, and thanks for contributing HAJO to the JAS (Java Acronym Soup) :-) Lars On 4/3/07, Spoonauer, Michael wrote: > > As our development teams begin to adopt the use of annotations within > their Java classes, we would like to prevent the devolution of those classes > into HAJOs (heavily annotated Java objects). Annotations make sense in some > contexts, but not in all. > > > > Does anyone know if a Checkstyle engine running against a Java SE 5.0class would be capable of determining what annotations have been defined > within that class (whether at the class, method or field level)? > > > > If that is possible, we would probably pursue the definition of a custom > check that limits the allowable annotations declared within a Java class to > a configurable white list. > > > > Thanks, > > Mike > ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Checkstyle-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/checkstyle-user