Re: Any Checkstyle users?
- From: "Chris Uppal" <chris.uppal@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: 31 Jan 2006 16:04:07 GMT
Roedy Green wrote:
[me:]
> > 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.
>
> How let us say the capacity factor is .75 and you set the size at
> 100. How big is the array inside 100 or 133? Not knowing that could
> give you poor performance with the beasts.
Good question! I had assumed that the capacity was the number of
actual entries expected -- regardless of load factor. But it seems
that the code intereprets it as the size of the array to allocate, with
the load factor determining how many of the occupied slots are allowed
before it grows itself.
In point of fact, the implementation rounds the capacity up to a power
of two.
Anyway, none of that's clear from the documentation -- which is
unforgivable. I don't care for the choice they've made for the
interpretation of "capacity" (in fact I think it's stupid), but leaving
the matter open to guesswork is <pauses, and chooses a less loaded
word> regrettable.
That being the case, my recommended identifier name is also wrong. I
leave it to the reader to find a managable identifier that expresses
the concept
Initial estimate of the probable maximum number of
expected guests, adjusted to take account of the (undocumented)
relationship between the "load factor" and "capacity" of a
java.util.HashMap.
Personally, I find that just
50
is as clear as anything ;-)
-- chris
.
- Follow-Ups:
- Re: Any Checkstyle users?
- From: Roedy Green
- Re: Any Checkstyle users?
- References:
- Any Checkstyle users?
- From: slippymississippi
- Re: Any Checkstyle users?
- From: mikm
- Re: Any Checkstyle users?
- From: mikm
- Re: Any Checkstyle users?
- From: Chris Uppal
- Re: Any Checkstyle users?
- From: Roedy Green
- Any Checkstyle users?
- Prev by Date: Re: tutorial on generics and threads and io
- Next by Date: synchronized class
- Previous by thread: Re: Any Checkstyle users?
- Next by thread: Re: Any Checkstyle users?
- Index(es):
Relevant Pages
|