Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Testing and the fly likes testing domain-model in DDD (subclass vs. interface-impl) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "testing domain-model in DDD (subclass vs. interface-impl)" Watch "testing domain-model in DDD (subclass vs. interface-impl)" New topic

testing domain-model in DDD (subclass vs. interface-impl)

manuel aldana
Ranch Hand

Joined: Dec 29, 2005
Posts: 308
in DDD you structure your design and code closely to the problem business area, which i think great. after reading some stuff about DDD something stay a bit unclear to me. respective papers never mentioned introducing interfaces for each domain model-element.

this way you can only inject dependencies by subclassing the production class and not passing an implementation of the interface, which i think "more natural" if i unit test.

example (passing by interface-impl, i usually prefer):

following would be more common from the stuff i read, where interfaces are hardly used, most likely because of the danger of having parallel hierachies everywhere -> each model-type has an interface type:

what kind of injection strategy do you follow when working with domain-models? the interface-impl or the subclass passing one?

thanks for your thoughts.

aldana software engineering blog & .more
I agree. Here's the link:
subject: testing domain-model in DDD (subclass vs. interface-impl)
It's not a secret anymore!