You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@roller.apache.org by Dave <sn...@gmail.com> on 2007/06/21 15:19:30 UTC

Proposal: Introduce DI with Guice

Now that the  EZ install/boostrapping work is complete in the trunk
and I've brought the roller_guice branch in line with the new regime,
I'm ready to start talking DI again. This is the last bit of work that
I'd like to get in before the 4.0 release.

Here's the start of the proposal:

This proposal introduces DI in Roller in a pretty limited way. The
idea is to get a DI framework into Roller so we can start rooting out
our various factories and singletons, making the code easier to test,
manage and providing more extension points.

As it stands today it's only benefits are that it 1) allows a
customizer to easily switch out Roller manager classes and replace
them with their own implementations and 2) make it possible for
RollerFactory to instantiate other Roller-dependent classes created by
folks who are customizing Roller.

These requirements are met by this proposal.

*  Introduce DI
** Use DI to setup the Roller instance and managers, i.e. manager
classes should no longer be hard-coded into the Roller implementation
class, instead they should be injected.
** Enforce singletons, i.e. singletons should have a private constructor.
** Use constructor injection to ensure that immutable objects remain immutable.

* Do not change Roller API
** Do not change the was Roller back-end interfaces are accessed by
front-end code
** i.e. RollerFactory.getRoller() stays in place

* Do not change way Roller is configured
** Do not introduce any additional configuration files for those
installing Roller, i.e. don't change the fact that the only
customization file users should ever have to touch is
roller-custom.properties.
** Do not introduce any additional configuration files for developers,
i.e. developers should not have to deal with any new XML or property
files.
** Maintain the same level of back-end pluggability, i.e. it should
still be possible to switch back-end implementations by setting a
single property in the Roller configuration file.


Read the rest here, with
http://cwiki.apache.org/confluence/display/ROLLER/Proposal+Introduce+DI+with+Guice

Comments?

- Dave

Re: Proposal: Introduce DI with Guice

Posted by Allen Gilliland <al...@sun.com>.
+1 to Guice from me.

Although, I'm not really convinced that your branch is properly in sync 
with the trunk.  For example the RollerFactory that you link to in the 
proposal is not in sync with the version in the trunk since the 
bootstrapped boolean was removed and the initialize() method was removed 
as well.

-- Allen


Dave wrote:
> Now that the  EZ install/boostrapping work is complete in the trunk
> and I've brought the roller_guice branch in line with the new regime,
> I'm ready to start talking DI again. This is the last bit of work that
> I'd like to get in before the 4.0 release.
> 
> Here's the start of the proposal:
> 
> This proposal introduces DI in Roller in a pretty limited way. The
> idea is to get a DI framework into Roller so we can start rooting out
> our various factories and singletons, making the code easier to test,
> manage and providing more extension points.
> 
> As it stands today it's only benefits are that it 1) allows a
> customizer to easily switch out Roller manager classes and replace
> them with their own implementations and 2) make it possible for
> RollerFactory to instantiate other Roller-dependent classes created by
> folks who are customizing Roller.
> 
> These requirements are met by this proposal.
> 
> *  Introduce DI
> ** Use DI to setup the Roller instance and managers, i.e. manager
> classes should no longer be hard-coded into the Roller implementation
> class, instead they should be injected.
> ** Enforce singletons, i.e. singletons should have a private constructor.
> ** Use constructor injection to ensure that immutable objects remain 
> immutable.
> 
> * Do not change Roller API
> ** Do not change the was Roller back-end interfaces are accessed by
> front-end code
> ** i.e. RollerFactory.getRoller() stays in place
> 
> * Do not change way Roller is configured
> ** Do not introduce any additional configuration files for those
> installing Roller, i.e. don't change the fact that the only
> customization file users should ever have to touch is
> roller-custom.properties.
> ** Do not introduce any additional configuration files for developers,
> i.e. developers should not have to deal with any new XML or property
> files.
> ** Maintain the same level of back-end pluggability, i.e. it should
> still be possible to switch back-end implementations by setting a
> single property in the Roller configuration file.
> 
> 
> Read the rest here, with
> http://cwiki.apache.org/confluence/display/ROLLER/Proposal+Introduce+DI+with+Guice 
> 
> 
> Comments?
> 
> - Dave

Re: Proposal: Introduce DI with Guice

Posted by Allen Gilliland <al...@sun.com>.

Anil Gangolli wrote:
> When I read the fine print on the proposal it basically sounds like we
> aren't really much real adoption of DI at all, and we are just
> introducing the use of Guice to wire the manager layer up.  


Yes, but that that is DI and it is important since the wiring of the 
backend is the primary way to extending Roller's core functionality.


> 
> I still think the choice of Guice over Spring is misguided in our
> context.  Annotation/code-based injection makes sense for the
> manager/persistence wire-up and other component bindings where
> non-committing developers are less likely to want to change things
> post-distribution, exactly where it's being used in this limited
> proposal.


I'm not understanding what you mean here.  You say it's misguided and 
then say it "makes sense" for the use case we are implementing here.


> 
> As it stands it's a small step in the DI direction and a more
> significant step towards adopting Guice rather than Spring for our DI
> basis, kind of the opposite of what I would have liked to see
> personally.  
> 
> If this is a way to get us comfortable with going further with DI, I'm
> all for it, because I want to see us go much further along that track.
> I'm more interested in the cleanliness, "pluggability" and
> "replaceability" we will get by adopting the DI model more fundamentally
> throughout Roller.


I think you are going to have to provide more info about what you mean 
by the "cleanliness, pluggability, and replaceability" we will get from 
your notion of DI.

As I said in my response to Denis' Spring work, I think that DI is an 
important pattern and we should be using it more than we do now, but I 
do not think it's the pattern for everything and IMO Spring (and most 
Spring advocates) tend to over emphasize DI.


> 
> +1 but with hesitation and another plea to consider Spring.


Spring was always considered, it's just that a number of us who spent a 
reasonable amount of time doing the comparison preferred Guice.

-- Allen


> 
> --a.
> 
> 
> On Thu, 2007-06-21 at 09:31 -0400, Elias Torres wrote:
>> I have been playing with Guice and I'm starting to like it.
>>
>> +1
>>
>> -Elias
>>
>> Dave wrote:
>>> Now that the  EZ install/boostrapping work is complete in the trunk
>>> and I've brought the roller_guice branch in line with the new regime,
>>> I'm ready to start talking DI again. This is the last bit of work that
>>> I'd like to get in before the 4.0 release.
>>>
>>> Here's the start of the proposal:
>>>
>>> This proposal introduces DI in Roller in a pretty limited way. The
>>> idea is to get a DI framework into Roller so we can start rooting out
>>> our various factories and singletons, making the code easier to test,
>>> manage and providing more extension points.
>>>
>>> As it stands today it's only benefits are that it 1) allows a
>>> customizer to easily switch out Roller manager classes and replace
>>> them with their own implementations and 2) make it possible for
>>> RollerFactory to instantiate other Roller-dependent classes created by
>>> folks who are customizing Roller.
>>>
>>> These requirements are met by this proposal.
>>>
>>> *  Introduce DI
>>> ** Use DI to setup the Roller instance and managers, i.e. manager
>>> classes should no longer be hard-coded into the Roller implementation
>>> class, instead they should be injected.
>>> ** Enforce singletons, i.e. singletons should have a private constructor.
>>> ** Use constructor injection to ensure that immutable objects remain
>>> immutable.
>>>
>>> * Do not change Roller API
>>> ** Do not change the was Roller back-end interfaces are accessed by
>>> front-end code
>>> ** i.e. RollerFactory.getRoller() stays in place
>>>
>>> * Do not change way Roller is configured
>>> ** Do not introduce any additional configuration files for those
>>> installing Roller, i.e. don't change the fact that the only
>>> customization file users should ever have to touch is
>>> roller-custom.properties.
>>> ** Do not introduce any additional configuration files for developers,
>>> i.e. developers should not have to deal with any new XML or property
>>> files.
>>> ** Maintain the same level of back-end pluggability, i.e. it should
>>> still be possible to switch back-end implementations by setting a
>>> single property in the Roller configuration file.
>>>
>>>
>>> Read the rest here, with
>>> http://cwiki.apache.org/confluence/display/ROLLER/Proposal+Introduce+DI+with+Guice
>>>
>>>
>>> Comments?
>>>
>>> - Dave
>>>
> 

Re: Proposal: Introduce DI with Guice

Posted by Dave <sn...@gmail.com>.
On 6/21/07, Matt Raible <ma...@raibledesigns.com> wrote:
> I like the idea of DI but Guice seems somewhat invasive to me, where
> it's likely less invasive to use something like Spring that doesn't
> require annotations in your code. However, I know this is a often-used
> initial reaction to Guice and despite it - lots of people love Guice.
> I wonder how many of those people are Spring users previous to Guice
> and how many are new to DI?
>
> Since Dave and Allen are the primary maintainers of Roller and they
> both like it, it's probably more their decision than anyones. Of
> course, that's not the Apache Way, but there's a lot of other wildly
> successful projects that operate that way.

I'm a pretty strong advocate of "the Apache Way" and following that
Apache way, we now appear to have consensus on the Guice proposal.
We've got three +1s and one +0 on it from committers and we didn't
even have to call for a vote.

I'll do some double checks to make sure I'm in sync with trunk and
then I'll go a careful merge from branches/roller_guice to trunk later
today.

Thanks,
- Dave

Re: Proposal: Introduce DI with Guice

Posted by Matt Raible <ma...@raibledesigns.com>.
+0

I like the idea of DI but Guice seems somewhat invasive to me, where
it's likely less invasive to use something like Spring that doesn't
require annotations in your code. However, I know this is a often-used
initial reaction to Guice and despite it - lots of people love Guice.
I wonder how many of those people are Spring users previous to Guice
and how many are new to DI?

Since Dave and Allen are the primary maintainers of Roller and they
both like it, it's probably more their decision than anyones. Of
course, that's not the Apache Way, but there's a lot of other wildly
successful projects that operate that way.

Matt

On 6/21/07, Dave <sn...@gmail.com> wrote:
> On 6/21/07, Anil Gangolli <an...@busybuddha.org> wrote:
> > When I read the fine print on the proposal it basically sounds like we
> > aren't really much real adoption of DI at all, and we are just
> > introducing the use of Guice to wire the manager layer up.
>
> Right, the proposal and code prove the concept and introduce DI. I
> think that there are many places where we can use DI in Roller, post
> 4.0, but now I'm primarily interested in 1) getting it into Roller and
> 2) using it now to make the back-end easier to extend.
>
>
> > I still think the choice of Guice over Spring is misguided in our
> > context.  Annotation/code-based injection makes sense for the
> > manager/persistence wire-up and other component bindings where
> > non-committing developers are less likely to want to change things
> > post-distribution, exactly where it's being used in this limited
> > proposal.
>
> Personally, I don't see any advantage of Spring's DI over Guice in any
> context. I believe we can get the extensibility we need across the
> board and more via Guice.
>
>
> > As it stands it's a small step in the DI direction and a more
> > significant step towards adopting Guice rather than Spring for our DI
> > basis, kind of the opposite of what I would have liked to see
> > personally.
> >
> > If this is a way to get us comfortable with going further with DI, I'm
> > all for it, because I want to see us go much further along that track.
> > I'm more interested in the cleanliness, "pluggability" and
> > "replaceability" we will get by adopting the DI model more fundamentally
> > throughout Roller.
>
> Yes, I think there are many places we'll be using DI moving forward,
> both in refactoring and adding more features.
>
>
> > +1 but with hesitation and another plea to consider Spring.
>
> I've considered Spring multiple times before for DI and other things.
> I've bought and read multiple books on Spring (Raible's Spring Live
> and Tate's Spring Dev. Notebook) and it never hooked me. In fact, I
> found it confusing and overarching. The reason I starting working with
> Guice is because I found it so much easier to work with than Spring.
> It hooked me from the start.
>
> - Dave
>


-- 
http://raibledesigns.com

Re: Proposal: Introduce DI with Guice

Posted by Dave <sn...@gmail.com>.
On 6/21/07, Anil Gangolli <an...@busybuddha.org> wrote:
> When I read the fine print on the proposal it basically sounds like we
> aren't really much real adoption of DI at all, and we are just
> introducing the use of Guice to wire the manager layer up.

Right, the proposal and code prove the concept and introduce DI. I
think that there are many places where we can use DI in Roller, post
4.0, but now I'm primarily interested in 1) getting it into Roller and
2) using it now to make the back-end easier to extend.


> I still think the choice of Guice over Spring is misguided in our
> context.  Annotation/code-based injection makes sense for the
> manager/persistence wire-up and other component bindings where
> non-committing developers are less likely to want to change things
> post-distribution, exactly where it's being used in this limited
> proposal.

Personally, I don't see any advantage of Spring's DI over Guice in any
context. I believe we can get the extensibility we need across the
board and more via Guice.


> As it stands it's a small step in the DI direction and a more
> significant step towards adopting Guice rather than Spring for our DI
> basis, kind of the opposite of what I would have liked to see
> personally.
>
> If this is a way to get us comfortable with going further with DI, I'm
> all for it, because I want to see us go much further along that track.
> I'm more interested in the cleanliness, "pluggability" and
> "replaceability" we will get by adopting the DI model more fundamentally
> throughout Roller.

Yes, I think there are many places we'll be using DI moving forward,
both in refactoring and adding more features.


> +1 but with hesitation and another plea to consider Spring.

I've considered Spring multiple times before for DI and other things.
I've bought and read multiple books on Spring (Raible's Spring Live
and Tate's Spring Dev. Notebook) and it never hooked me. In fact, I
found it confusing and overarching. The reason I starting working with
Guice is because I found it so much easier to work with than Spring.
It hooked me from the start.

- Dave

Re: Proposal: Introduce DI with Guice

Posted by Sam Neth <sa...@onthefly.com>.
I agree with the misgivings expressed in this post, and I think Guice is 
going to be a snazzy mistake, but it was evident pretty quickly that it 
was going to be an uphill battle to sell that.  I don't have the time 
for uphill battles, and I accept the possibility that I just don't get 
it.  Bob Lee may have sharp elbows, but he's clearly a smart dude, and 
Guice is definitely cool.  If nothing else I'm concerned that Guice is 
not going to enable the kind of creative rewiring that Spring does, 
because as I recall you have to anticipate potential customization 
points and go out of your way to externalize the wiring.  I expect this 
would tend to produce a code base that's elegantly modular only from the 
inside.  I won't mind having some exposure to a project built on Guice 
though, so w/e.

Anil Gangolli wrote:
> When I read the fine print on the proposal it basically sounds like we
> aren't really much real adoption of DI at all, and we are just
> introducing the use of Guice to wire the manager layer up.  
>
> I still think the choice of Guice over Spring is misguided in our
> context.  Annotation/code-based injection makes sense for the
> manager/persistence wire-up and other component bindings where
> non-committing developers are less likely to want to change things
> post-distribution, exactly where it's being used in this limited
> proposal.
>
> As it stands it's a small step in the DI direction and a more
> significant step towards adopting Guice rather than Spring for our DI
> basis, kind of the opposite of what I would have liked to see
> personally.  
>
> If this is a way to get us comfortable with going further with DI, I'm
> all for it, because I want to see us go much further along that track.
> I'm more interested in the cleanliness, "pluggability" and
> "replaceability" we will get by adopting the DI model more fundamentally
> throughout Roller.
>
> +1 but with hesitation and another plea to consider Spring.
>
> --a.
>
>
> On Thu, 2007-06-21 at 09:31 -0400, Elias Torres wrote:
>   
>> I have been playing with Guice and I'm starting to like it.
>>
>> +1
>>
>> -Elias
>>
>> Dave wrote:
>>     
>>> Now that the  EZ install/boostrapping work is complete in the trunk
>>> and I've brought the roller_guice branch in line with the new regime,
>>> I'm ready to start talking DI again. This is the last bit of work that
>>> I'd like to get in before the 4.0 release.
>>>
>>> Here's the start of the proposal:
>>>
>>> This proposal introduces DI in Roller in a pretty limited way. The
>>> idea is to get a DI framework into Roller so we can start rooting out
>>> our various factories and singletons, making the code easier to test,
>>> manage and providing more extension points.
>>>
>>> As it stands today it's only benefits are that it 1) allows a
>>> customizer to easily switch out Roller manager classes and replace
>>> them with their own implementations and 2) make it possible for
>>> RollerFactory to instantiate other Roller-dependent classes created by
>>> folks who are customizing Roller.
>>>
>>> These requirements are met by this proposal.
>>>
>>> *  Introduce DI
>>> ** Use DI to setup the Roller instance and managers, i.e. manager
>>> classes should no longer be hard-coded into the Roller implementation
>>> class, instead they should be injected.
>>> ** Enforce singletons, i.e. singletons should have a private constructor.
>>> ** Use constructor injection to ensure that immutable objects remain
>>> immutable.
>>>
>>> * Do not change Roller API
>>> ** Do not change the was Roller back-end interfaces are accessed by
>>> front-end code
>>> ** i.e. RollerFactory.getRoller() stays in place
>>>
>>> * Do not change way Roller is configured
>>> ** Do not introduce any additional configuration files for those
>>> installing Roller, i.e. don't change the fact that the only
>>> customization file users should ever have to touch is
>>> roller-custom.properties.
>>> ** Do not introduce any additional configuration files for developers,
>>> i.e. developers should not have to deal with any new XML or property
>>> files.
>>> ** Maintain the same level of back-end pluggability, i.e. it should
>>> still be possible to switch back-end implementations by setting a
>>> single property in the Roller configuration file.
>>>
>>>
>>> Read the rest here, with
>>> http://cwiki.apache.org/confluence/display/ROLLER/Proposal+Introduce+DI+with+Guice
>>>
>>>
>>> Comments?
>>>
>>> - Dave
>>>
>>>       
>
>   


Re: Proposal: Introduce DI with Guice

Posted by Anil Gangolli <an...@busybuddha.org>.
When I read the fine print on the proposal it basically sounds like we
aren't really much real adoption of DI at all, and we are just
introducing the use of Guice to wire the manager layer up.  

I still think the choice of Guice over Spring is misguided in our
context.  Annotation/code-based injection makes sense for the
manager/persistence wire-up and other component bindings where
non-committing developers are less likely to want to change things
post-distribution, exactly where it's being used in this limited
proposal.

As it stands it's a small step in the DI direction and a more
significant step towards adopting Guice rather than Spring for our DI
basis, kind of the opposite of what I would have liked to see
personally.  

If this is a way to get us comfortable with going further with DI, I'm
all for it, because I want to see us go much further along that track.
I'm more interested in the cleanliness, "pluggability" and
"replaceability" we will get by adopting the DI model more fundamentally
throughout Roller.

+1 but with hesitation and another plea to consider Spring.

--a.


On Thu, 2007-06-21 at 09:31 -0400, Elias Torres wrote:
> I have been playing with Guice and I'm starting to like it.
> 
> +1
> 
> -Elias
> 
> Dave wrote:
> > Now that the  EZ install/boostrapping work is complete in the trunk
> > and I've brought the roller_guice branch in line with the new regime,
> > I'm ready to start talking DI again. This is the last bit of work that
> > I'd like to get in before the 4.0 release.
> > 
> > Here's the start of the proposal:
> > 
> > This proposal introduces DI in Roller in a pretty limited way. The
> > idea is to get a DI framework into Roller so we can start rooting out
> > our various factories and singletons, making the code easier to test,
> > manage and providing more extension points.
> > 
> > As it stands today it's only benefits are that it 1) allows a
> > customizer to easily switch out Roller manager classes and replace
> > them with their own implementations and 2) make it possible for
> > RollerFactory to instantiate other Roller-dependent classes created by
> > folks who are customizing Roller.
> > 
> > These requirements are met by this proposal.
> > 
> > *  Introduce DI
> > ** Use DI to setup the Roller instance and managers, i.e. manager
> > classes should no longer be hard-coded into the Roller implementation
> > class, instead they should be injected.
> > ** Enforce singletons, i.e. singletons should have a private constructor.
> > ** Use constructor injection to ensure that immutable objects remain
> > immutable.
> > 
> > * Do not change Roller API
> > ** Do not change the was Roller back-end interfaces are accessed by
> > front-end code
> > ** i.e. RollerFactory.getRoller() stays in place
> > 
> > * Do not change way Roller is configured
> > ** Do not introduce any additional configuration files for those
> > installing Roller, i.e. don't change the fact that the only
> > customization file users should ever have to touch is
> > roller-custom.properties.
> > ** Do not introduce any additional configuration files for developers,
> > i.e. developers should not have to deal with any new XML or property
> > files.
> > ** Maintain the same level of back-end pluggability, i.e. it should
> > still be possible to switch back-end implementations by setting a
> > single property in the Roller configuration file.
> > 
> > 
> > Read the rest here, with
> > http://cwiki.apache.org/confluence/display/ROLLER/Proposal+Introduce+DI+with+Guice
> > 
> > 
> > Comments?
> > 
> > - Dave
> > 


Re: Proposal: Introduce DI with Guice

Posted by Elias Torres <el...@torrez.us>.
I have been playing with Guice and I'm starting to like it.

+1

-Elias

Dave wrote:
> Now that the  EZ install/boostrapping work is complete in the trunk
> and I've brought the roller_guice branch in line with the new regime,
> I'm ready to start talking DI again. This is the last bit of work that
> I'd like to get in before the 4.0 release.
> 
> Here's the start of the proposal:
> 
> This proposal introduces DI in Roller in a pretty limited way. The
> idea is to get a DI framework into Roller so we can start rooting out
> our various factories and singletons, making the code easier to test,
> manage and providing more extension points.
> 
> As it stands today it's only benefits are that it 1) allows a
> customizer to easily switch out Roller manager classes and replace
> them with their own implementations and 2) make it possible for
> RollerFactory to instantiate other Roller-dependent classes created by
> folks who are customizing Roller.
> 
> These requirements are met by this proposal.
> 
> *  Introduce DI
> ** Use DI to setup the Roller instance and managers, i.e. manager
> classes should no longer be hard-coded into the Roller implementation
> class, instead they should be injected.
> ** Enforce singletons, i.e. singletons should have a private constructor.
> ** Use constructor injection to ensure that immutable objects remain
> immutable.
> 
> * Do not change Roller API
> ** Do not change the was Roller back-end interfaces are accessed by
> front-end code
> ** i.e. RollerFactory.getRoller() stays in place
> 
> * Do not change way Roller is configured
> ** Do not introduce any additional configuration files for those
> installing Roller, i.e. don't change the fact that the only
> customization file users should ever have to touch is
> roller-custom.properties.
> ** Do not introduce any additional configuration files for developers,
> i.e. developers should not have to deal with any new XML or property
> files.
> ** Maintain the same level of back-end pluggability, i.e. it should
> still be possible to switch back-end implementations by setting a
> single property in the Roller configuration file.
> 
> 
> Read the rest here, with
> http://cwiki.apache.org/confluence/display/ROLLER/Proposal+Introduce+DI+with+Guice
> 
> 
> Comments?
> 
> - Dave
>