Since no one seems to have an opinion about this either way, I think
I'm going to use Josh Bloch's approach of a nested internal class -
this way things stay consistent with a well-known piece of literature
and it is easily 'findable' when looking at the Subject interface.

- Les

On Tue, Aug 25, 2009 at 2:37 PM, Les Hazlewood<[email protected]> wrote:
> In setting up the Builder design pattern for constructing instances,
> I've currently created the SubjectBuilder and a WebSubjectBuilder
> classes.
>
> In Josh Bloch's "Effective Java", Second Edition, Item #2 (page 11),
> he advocates the Builder pattern for the exact same reasons why I've
> added the above classes.  But his Builder classes are nested classes
> within the class/interface being built.  That is:
>
> public ClassToBuild {
> ...
>    public static class Builder {
>    }
> ...
> }
>
> My question is:
>
> Should SubjectBuilder be changed to Subject.Builder (a nested public
> static class in the Subject interface) or keep SubjectBuilder?
>
> My initial thought is to change to Subject.Builder to
>
> 1) keep it consistent with a widely read piece of literature that
> people are readily familiar with and
> 2) being in the Subject interface inherently makes it easier to find
> by people reading the JavaDocs.
>
> That is, as an end user, I probably wouldn't know that a Builder
> existed for Subject instances unless someone told me.  But if I saw it
> in the Subject interface, probably the most widely referenced
> interface in the framework, it would be easier to learn to use since I
> couldn't avoid seeing it if I tried ;)
>
> Thoughts?
>
> Les
>

Reply via email to