views:

83

answers:

2

I came across the term "domain object" and found a couple of definitions on Google but I just want to verify that my understanding is correct.

Is this simply any class that represents business rules - since the word 'domain' usually means rules that are specific to some local problem set such as how to calculate income taxes.

So the domain objects for calculating income taxes would be the classes that you write to represent all of the tax rules?

+2  A: 

That would be a Domain Service. A Domain Object would be something like Income or TaxPayer. That object could have a Taxes property that calls the Domain Service to calculate the amount of taxes due according to the rules for example.

GoodEnough
So the domain object is a noun; the domain service is a verb. If I understand you, the domain object doesn't perform any actions by itself - it merely represents some set of attributes - and it's acted upon by the domain service.
tom w.
That's what some people would call an "anemic domain model". The domain object becomes little more than a data transfer object with no significant behavior. It's one way to do things, but by no means the only way.
duffymo
@tom w: The domain object can perform some actions, but only minor calculations. For more complex rules like calculating taxes, a domain service is usually the way to go.@duffymo: indeed, not the only way
GoodEnough
@Crossbrowser: Thanks. Is your description the most common understanding of the term?
tom w.
@tom w: I wouldn't know but I have over 2 years of experience in Domain-Driven Design and that's how we see things where I work.
GoodEnough
@Crossbrowser - But, as duffymo pointed out, and I believe you agreed (?), a domain service is not a requirement? So the domain object could represent and carry out all of the tax rules by itself, without referring to a Domain Service. Is that correct?
tom w.
@tom w: No one would stop you, but that is not the "correct" way of doing things. As I said, my domain objects do implement a little logic.
GoodEnough
+2  A: 

A domain object is any object that represents a given entity in your business domain. There are several flavors of this. Generally speaking however domain objects hold data and any rules for the eitity that is being modeled. Some choose to phisically seperate these concerns so that the business rules are not processes in the same object as the data. Whatever implementation you choose domain objects logically group data and rules in a modular way.