Hi,

I'd like some advise on the use of assisted injection. 

Most of the example that i saw about assisted injection, have the following 
characteristic:


   - The class being constructor has a parameter, that comes one or more 
   parameter that only comes at runtime, that is, that can't be determined at 
   construction time, and one or many parameters that are known at 
   construction time. Hence, the create method of the factory only takes, the 
   parameter provided at runtime.


In my case 90% of the time, i just have the runtime parameter. Meaning, I 
have a class A that needs a class B, but B takes parameters that only A can 
provide. So there is only @assister Parameter in the constructor of B. 

I'm wondering if that is the proper usage of assisted injection. 

One of my last example is the following. A needs to return a class B that 
is a "dataStructure" (sometimes called DTO, or value object), hence i pass 
to A the necessary factory, so that after its computation he can return 
B.Here B, is like a container class.  I have few case like that. 

The other situation is when service A needs the B Service, but B service 
depends of a Parameter from A upon creation. Where the parameter from A his 
himself injected to A, however, A does some initialization on it, before 
creating B with it.

Especially in the last case shall i aim to do the *"internal initialization 
of A"* outside of A. *The idea is to have specific creation modules in each 
package, that externalizes the "internal creation of the services" of that 
package? I'm saying this because I always thought that, creating things 
somewhere that is unrelated to the class/service that is going to use it 
sounds odd to me. With my current understanding, each package should 
provide its creation module, that centralizes the creation of the object 
that it contains, especially if one use private constructors.*

I have used Guice so far for a while, but it is just recently that i red 
something about separating module, and keeping module with their package. I 
use to do inheritance between module to chain the creation of object, and 
ended up having one module that creates everything from start. That is 
wrong right ?

So that is it. I would appreciate some general advice on the right approach 
in using Guice. I'm not sure that i'm using assisted injection the right 
way.


-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-guice/0c1d671d-7d74-46b9-a9ba-2ef7685fad1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to