On Sat, Jul 31, 2010 at 7:11 AM, Markus Zywitza
<[email protected]> wrote:
> I had a problem when I started migrating to repositories: I wanted to
> actually use a rich object model, but I needed repositories at all
> places where I couldn't inject them. For example, in a software
> license management LOB application, I let the software figure out
> whether it has still a valid combination of required unused licenses.
> Since I didn't want to keep a list of license instance along with the
> software, I needed an license instance repository. But how to get one
> into the entity object?
> I ended up with a domain service which at the end is nothing but the
> undead transaction script zombied into object model, draining logic
> from it so that the model becomes anemic.

There's nothing wrong with passing a LicenseRepository into a method
on the Software class. This allows easy testing and also stops
coupling your models to persistence.

class Software{
   bool IsValidLicenseCombination(LicensesRepository repo) {
      var licenses = repo.FindValidLicenses(this,...);
      ....
   }
}

This doesn't end up with an anemic model or a transaction script.
Although you still need to have the repo somewhere to pass in.

j.

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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/castle-project-users?hl=en.

Reply via email to