Hi Brendan - in my experience, injecting DAOs into the domain model
does make it a little more difficult to unit-test your domain model.

I agree with Stuart that you should use the interface for the DAO when
doing this.

However, consider the situation where your DAO has a large number of
methods and you want to unit test a part of your domain model that
needs the DAO. It now becomes difficult to determine how many of the
DAO inteface members you actually need to provide an implementation
for, without actually looking at the code under test. Moreover as time
goes by, you tend to forget the details, which in turn causes the
tests to be difficult to understand.

Having injected DAO into the domain model in the past, I am now trying
to avoid it. At one point I actually injected the whole DaoFactory
into the domain model. It turned out to be a very bad call, as it
became very difficult to test anything.

Instead, I sometimes create "Command" objects which I guess is
equivalent to Rauls "components."

Hope this helps.  :-)

Regards
Thomas




On 29 Aug., 04:09, Brendan Erwin <[email protected]> wrote:
> I'm thinking of wiring up StructureMap to provide IoC within NH so I  
> can inject my DAOs into my domain models.
>
> In doing the research I see a lot of people speaking out against  
> having dependencies in ones domain, but the way I see it my data  
> access strategies and policies are part of my domain. How wrong am I?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" 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/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to