I'm been reading, and have now seen two different implementations of the Unit of Work pattern. The first pattern has the Repository talking to the Unit of Work to a domain object.
The other implementation has the Service layer registering the domain object as modified:
I guess my question is, what are the benefits/drawbacks to each? I know that is lot to answer without providing some implementation code for the repositories/mappers/etc... but in general, who/what should really be responsible for "newing up" the UoW and then working with it?
My thought is if you let the Repository handle it, it should be provided as a injectable interface to the repository(s) so the same UoW can span multiple repositories (aka, multiple domain objects)...
If the service layer handles it, then you're kind of "stuck" with only one UoW implementation per Service Layer call (example, ServiceLayer.AddCustomer(customer)).
In the web world, I can't see multiple service layers being called for different domain objects... but maybe in the non-web world I can.
I imagine something eventually has to call "commit()", so it makes the most sense to have that tied into the Service Layer.
Thanks, Mike