Re: Any Checkstyle users?
- From: "Chris Uppal" <chris.uppal@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 31 Jan 2006 11:42:01 -0000
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.
-- chris
.
- Follow-Ups:
- Re: Any Checkstyle users?
- From: Roedy Green
- Re: Any Checkstyle users?
- From: Rick Giles
- Re: Any Checkstyle users?
- References:
- Any Checkstyle users?
- From: slippymississippi
- Re: Any Checkstyle users?
- From: mikm
- Re: Any Checkstyle users?
- From: mikm
- Any Checkstyle users?
- Prev by Date: Re: platform's default charset ?
- Next by Date: Re: Generics and forName()
- Previous by thread: Re: Any Checkstyle users?
- Next by thread: Re: Any Checkstyle users?
- Index(es):