> as pointed out by jeffrey i could also pass in the services as needed
> but i think this approach will bloat the methods of my domain objects.
> have you used this approach on a big codebase? doesn't it have some
> negative effects on the expressiveness of the Domain Objects?

When some domain logic need to use some service, I think there are 3 ways to
get that service :

* passed as parameter
* injected into domain object
* pulled the service out from some registry in a method

To my humble opinion, "passed as parameter" is the most clean way to make
domain object reusable. 
For example, if you have an Order domain object, needs a TaxCaculator
service in some method.  You could pass either a USATaxCaculator or
CanadaTaxCaculator in.  The other ways don't provide this flexibility. 

Only if you are sure that a service will only have one implementation in
your system for domain object use, you  might  choose the 2nd or the 3rd
way. In this case, I am favoring the 3rd way.

P.S. 
We have used the combination of 1st and 3rd way in a medium-scale e-commerce
software.

Cheers,
Jeffrey Ai


-- 
View this message in context: 
http://www.nabble.com/-T5--injecting-services-into-Domain-Objects-tp14250305p14279147.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to