[concurrency-interest] RFC -- Java7 java.util.concurrent plans

Bob Lee crazybob at crazybob.org
Sat Dec 13 13:24:37 EST 2008


On Sat, Dec 13, 2008 at 3:56 AM, Osvaldo Pinali Doederlein <
osvaldo at visionnaire.com.br> wrote:

> (*) One could argue that names like "Weak" would look odd, incomplete: weak
> what? But after Java5's generics you wouldn't write "Weak buffer", you write
> "Weak<Image> buffer" that looks much better. It seems that post-generics,
> naming style should often consider the full composition with generic
> parameters. Although that's a difficult, case-by-case reasoning... for a
> scenario like Weak<Image>, the Weak component looks like a trait, as one
> reads "a weak image". Better style for Scala? ;-)
>

I think the naming rules differ a bit for nouns vs. adjectives among other
things.

>From a usability standpoint, we should also consider the verbosity of the
user's code and whether or not they'll have to wrap lines. JBoss's CRHM
currently requires you to write something like this(*):

    static final ConcurrentMap<String, Data> cache
            = new ConcurrentReferenceHashMap<String, Data>(
                        ConcurrentReferenceHashMap.ReferenceType.STRONG,
                        ConcurrentReferenceHashMap.ReferenceType.SOFT);

Here's how it would look with a shorter name:

    static final ConcurrentMap<String, Data> cache
            = new ReferenceMap<String,
Data>(ReferenceMap.ReferenceType.STRONG,
                        ReferenceMap.ReferenceType.SOFT);

I actually think we should use a builder:

    static final ConcurrentMap<String, Data> cache
            = new ReferenceMap.Builder().softValues().build();

Bob

(*) CRHM actually requires you to explicitly specify the capacity, load
factor and concurrency level, too:
http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbosscache/experimental/jsr166/src/jsr166y/ConcurrentReferenceHashMap.java?revision=5470&view=markup&pathrev=5470
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20081213/a2cf1e0c/attachment.html>


More information about the Concurrency-interest mailing list