Request for comments: Bug 6306820
Alan Bateman
Alan.Bateman at Sun.COM
Tue May 22 01:15:57 PDT 2007
Richard Kennard wrote:
> Alan,
>
> Thanks for your continued support.
>
> I find the 'static factory method' approach interesting, but I'm a
> little confused. You cite 'being able to return a subclass' as an
> advantage. However, you also recommend a private constructor and
> classes with private constructors can never be subclassed?
Josh Bloch's Effective Java provides good coverage of this topic if you
are interested. In this case the static factory methods that you define
will create the UrlQueryString instances and they can return different
subtypes if required. This might not be necessary now but in the future
there may be differnt standards for encoding parameters and to support
that you could add a new static factory method that returns a
UrlQueryString that supports that mechanism. If it becomes necessary to
return subtypes from other classes in the package then you could make
the constructors package-private but for the current proposal it
probably isn't necessary.
-Alan.
More information about the net-dev
mailing list