You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shiro.apache.org by Les Hazlewood <lh...@apache.org> on 2009/08/25 20:37:33 UTC

SubjectBuilder or Subject.Builder ?

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

Re: SubjectBuilder or Subject.Builder ?

Posted by Kalle Korhonen <ka...@gmail.com>.
I don't have strong opinions, but I've used the same pattern (nested
internal classes) on several occasions, so I agree with your choice.

Kalle


On Fri, Aug 28, 2009 at 6:50 AM, Les Hazlewood<lh...@apache.org> wrote:
> 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<lh...@apache.org> 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
>>
>

Re: SubjectBuilder or Subject.Builder ?

Posted by Les Hazlewood <lh...@apache.org>.
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<lh...@apache.org> 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
>