Hi,
I've been unable to find a suitable answer to this question.
If I understand this correctly: Dependency Injection can be used to
instantiate service objects -- object that essentially abstract away
some computational service ... for example (an instance of this class
would essentially be stateless, save for resources that it might be
plugged into such as SimpleMath.properties, and I would expect that
there would be small number of instances of this class per application
instance say under 5):
class SimpleMath {
public int addTwoNumbers (int n1, int n2) {
return n1 + n2;
}
public int multiplyTwoNumbers (int n1, int n2) {
return n1 * n2;
}
}
Now can DI be used to instantiate value objects (for the lack of a
better word). By a value object I mean an object that has state and
the methods are impacted by that state, for example (as opposed to the
previous class I would expect there to be hundreds or thousands of
instances of this class):
class Person {
int age;
int weight;
String fname;
String lname;
// and so on
public String hail() {
return "Hello to you to, I am " + fname + " " + lname;
}
public String howOldAreYou() {
return "I don't really like talking about my age but I'm " + age +
" years young";
}
// and so on
}
Thanks.
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.