views:

125

answers:

1

Are many-to-many table structures defined as Value Objects in DDD? What if my many-to-many structure has a unique id? Also, what about 1-to-many relationships? For instance, if i have 2 structures Post & Comment with 1-to-many (respectively) wouldn't Comment be a Value Object since it technically cannot exist without a corresponding Post? But what if it has a unique Id (Comment_Id)? That makes it identifiable and therefore a non-value object entity? So, which is it?

Thanks!

+1  A: 

You are probably do not need DDD for blog. DDD is more about business logic. You will not have enough business logic to benefit from DDD.

If you still want to use DDD, not a problem. Some guidelines:

  1. If you want something to be referensable from outside of the business logic, it should be entity. So if you need reference to comments (otherwise you will not be able to manage them effectively) you need your comments to be an entities.
  2. You have to maximize persistence ignorance. This means that could not expose identifiers to your business logic.
  3. Many-to-many and one-to-many relationships are modeled with plain collections. The ORM tool should map this collections properly.

Hope this helps to avoid DDD in your situation.

Mike Chaliy
I'm not designing a blog. The example i gave was just something I thought many are familiar with, and which shows the same issue i have with my model.
Sergey
You are not simply asking direction. You ask what direction with aircraft. And my answer is not to use aircraft, because for half a mile this will be less than optimal solution. Does goal of my answer clear?
Mike Chaliy
@unknown (google), how do you edit your comments?
Mike Chaliy
Hey Mike, I was the one who made the remark about directions but since you answered I deleted my comment and voted your answer up. Maybe your confusing unknown and I.
jfar
aha, yep, seems so.
Mike Chaliy