Here is a rather dumb but perfectly valid question from a newbie. Context: My "domain object" includes a title (plus some other characteristics, but they're not important). This title is produced based on some designs that are defined within the database. Now... who must decide the title from the domain object? If the domain object determine it's own title (please be aware this "title" could be based by itself as well as other object's characteristics) or should something determine the title based on the pattern after which call something similar to

domainObject.setName(theActualName)

I am inclined to stick to the "service" approach, but however it appears this ought to be an item-specific behavior.

Thanks for the replies.

I believe you should think about Tell Don't Request Principle

If object consists of all of the data it must calculate its title I'd put this process on that class. If the data is dependant on other object's characteristics and parent class also consists of this child object that consists of data, I'd again placed on parents class.

Just Make it simple. I wouldn't introduce something class basically dont actually need. In DDD terms you need to put your domain related logic in domain classes .

This can be a domain object that consists of logic? If so, I'd rather provide a mention of the DAO and allow it to decide its title by itself. In by doing this your logic is going to be near your computer data.

A few issues bear about this:

  1. Do you want some kind of control over what they are called? (A good example will be a directory to find information about an item by title.) If that's the case, get a service. (An alternate is always to request each domain resist register itself once it understands its title.)
  2. Would be the domain objects realistically in addition to the database once they've been produced and names? If that's the case, then it might be sound practice to ensure that they're independent by putting the information base dependence inside a service.

When the domain objects will be associated with the information base anyway, and when there's you don't need to centrally manage what they are called, i quickly would believe that getting the domain objects title themselves leads toward greater object cohesion.