Re: Any Checkstyle users?



On Tue, 31 Jan 2006 14:03:54 -0000, <slippymississippi@xxxxxxxxx> wrote:

BTW, it appears (from more recent posts in the thread) that the issue wasn't
the use of a magic number at all, but of a variable of type HashMap.

Not just HashMap:

"java.util.GregorianCalendar, java.util.Hashtable, java.util.HashSet,
java.util.HashMap, java.util.ArrayList, java.util.LinkedList,
java.util.LinkedHashMap, java.util.LinkedHashSet, java.util.TreeSet,
java.util.TreeMap, java.util.Vector"

I suppose the check is pushing me to pass/return custom data objects
that implement Java-specific data structures behind the scenes?  I
can't see how  you would write meaningful code without eventually using
one of the listed data structures, but I can see vaguely how it would
be beneficial to wrapper the implementation of these data structures.

It seems to be advocating that you return java.util.Calendar, java.util.Map, java.util.Set, java.util.List, etc. In other words, return the interface type rather than the concrete implementation. No need to write any wrappers.


Dan.


-- Daniel Dyer http://www.dandyer.co.uk .