Re: Any Checkstyle users?



Chris Uppal wrote:
mikm wrote:

{   private HashMap guests;
    private static final int MAX_GUESTS = 50;
    //...
   public Hotel()
   {   guests = new HashMap(MAX_GUESTS);
[...]
Now, anybody looking at your code knows that the maximum number of
guests is 50 and that the HashMap "guests" can hold that much data.

Except that that isn't true. The name should be something like private static final int INITIAL_ESTIMATE_OF_PROBABLE_MAX_GUESTS = 50; which is unwieldy in the extreme, but calling it MAX_GUESTS is actively wrong and so must be avoided.

The real problem here is not the use of a "magic number", but the use of a
checking tool which will blindly apply the same so-called rule to every
situation, regardless of whether it is applicable.  If Checkstyle doesn't
provide a way to annotate your code to say "I have reviewed this 'problem' code
and it is fine as it is", then I'd suggest dropping Checkstyle.

Yes, it does; see SuppressionCommentFilter at http://checkstyle.sourceforge.net/config.html

/RG

    -- chris



.