[infinispan-dev] Components and their fields

Galder Zamarreno galder at jboss.org
Wed Apr 14 05:10:55 EDT 2010


----- "Manik Surtani" <manik at jboss.org> wrote:

> On 13 Apr 2010, at 16:34, Vladimir Blagojevic wrote:
> 
> > Hi,
> > 
> > Shouldn't we strive to minimize the number of fields in composite
> components that we create. I am working with StateTransferManagerImpl,
> DistributionManagerImpl and they both have so many fields it is
> overwhelming :)
> > 
> > Why don't we inject AdvancedCache instead and then get references
> through it?
> 
> We could, but then AdvancedCache becomes a registry of sorts.  And
> also makes it harder to unit test (as you will then *always* need an
> AdvancedCache stub).

If you want to reduce the number of parameters, you could simply inject (Global)ComponentRegistry, which are the actual registries and retrieve the necessary components from there. If some of those parameters are only used once, it might make sense to do this. Otherwise, if they're used multiple times, you might as well inject the parameter directly.

> 
> Cheers
> --
> Manik Surtani
> manik at jboss.org
> Lead, Infinispan
> Lead, JBoss Cache
> http://www.infinispan.org
> http://www.jbosscache.org
> 
> 
> 
> 
> 
> _______________________________________________
> infinispan-dev mailing list
> infinispan-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/infinispan-dev



More information about the infinispan-dev mailing list