+1  A: 

In a Blog application, a Post is an Entity and a Tag is a value object. A Tag hasn't got identity. You should have:

  • PostsRepository
  • Post (Entity)
  • Tag (value object)

A Post has got a list of tags.

Questions:

1 : I have also read that it is not good practice to have a domain entity converse with a domain service. Is this true?

Yes, itsn't a good practice. You entity hasn't want to be coupled with a domain service. If you do that, then you couldn't reuse them later. Did you have consider to fire a domain event. You can tell your service domain do something fire domain events.

2. : Is it ok to get a reference to the PostServices domain service via a factory creation method. e.g..IPostService PostService = ServiceUtil.GetPostService(); return PostService.GetTags(Post.content);

Yes, it's possible. A factory method could return an abstract class or an interface. This is a good Software Design Principle "code to an interface not to an implementation". If you do this, you'll be able to change your implementation later and you won't have to change yout client code.

3 : Is it acceptable to have the domain service coupled to a third party api?

I don't recommend you this, but it is acceptable.

Sorry, I don't understand question 4.

Look this link. I hope it help you.

http://stackoverflow.com/questions/901462/ddd-where-is-it-most-appropriate-to-get-a-list-of-value-objects/901562#901562

yeraycaballero
Thanks for the answer, however I am still a little unclear. Are you suggesting that the Post entity uses a factory to obtain a reference to a domain service which supplies tags.Also Tags are unique in my system and are identified via a primary key does this mean they are an entity ?
sjb101
I have just found the following link which offers a good explanation of Value objects...http://tech.groups.yahoo.com/group/domaindrivendesign/message/6290So Tag should be value object. Anyway back to the main question above......
sjb101
No, Post has got a List of tags. And you could retrieve tags from PostsRespository. A blog is a easy domain. You only have posts, tags, and comments. I don't undestand why you need a domain service. What is the responsability of yout domain service?
yeraycaballero
To me, it still looks like the tags are «entities» since they seem to be shared among the posts (a m2m relationship), and have a primary key.How can they be «value objects»?
Martin R-L
yeraycaballero - The main question was where would I handle the call to a third party API web service which returns a list of tags based on the content of a post.Should it be directly from in the Post domain entity?Function Post.BuildTag()tags = externalapiservice.gettags(me.content)end
sjb101
Martin R-L - I think I agree with you... Tags have related posts and by association potentially related comments. I'm pretty confused with the whole value object thing. Can anyone shed any light? Tag = value object or entity?
sjb101
An entity is something which has identity and a life cycle. For example a Customer is an entity. His address or his mobile phone can be changed during his life, but he is the same Customer. A Value object is a property o feature of an entity. The main feature of a value object is that it is inmutable. You can't change a tag. If you change a tag, it'll be a new tag. Value objects have a lot of benefits: - Value objects can be reused in different entities - Help you to Reveal intention of your code - They are inmutable (safe thread) - Let you optimize your memory using fly-weight pattern
yeraycaballero