Sunday, March 6, 2005

A couple of views on coupling

Having read both Domain Driven Design and Hibernate in Action recently, I found an interesting contradiction between them...here's what Eric Evans has to say about promiscuous coupling between your domain classes:

"It is important to constrain relationships as much as possible. A bidirectional association means that both objects can be understood only together. When application requirements do not call for traversal in both directions, adding a traversal direction reduces interdependence and simplifies the design. Understanding the domain may reveal a natural directional bias."

...and here's what Gavin King and Christian Bauer have to say on the same subject:

"Good uses for unidirectional one-to-many associations are uncommon in practice, and we don�t
have one in our auction application. You may remember that we started with the
Item and Bid mapping in chapter 3, making it first unidirectional, but we quickly
introduced the other side of the mapping."

So I agree with Eric, but I'm using Hibernate. Things that make you go hmmmm....