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