Typically the objects in a domain model can be categorized into 2 types: entities and value objects. Both of these can be implemented as regular CLS objects with properties and methods, they represent domain concepts and provide methods that manipulate the internal state. So what’s the difference then? Well, some objects require specific identity management, where a mistake in identity can lead to data corruption. Can you imagine assigning a million dollar contract to the wrong business partner? Obviously a BusinessPartner requires carefull identity management to prevent catastrophic errors in the system. These kinds of objects are called entities.
Remember that objects, when they are in memory, are identified by their memory address and not some property that acts as an identifier like this is the case in a relational database. The underlying infrastructure must ensure that the two are mapped to one another, which is often done using the identity map design pattern. Implementing such an infrastructure can be a pretty daunting task, but if you are interested, I have created an entire series of blog posts last year which covers most of the difficulties that you will encounter. Or, you could use an Object Relational Mapper instead.
On the other hand, a domain model contains a lot of Value Objects as well, which will be covered in the next post.
Stay tuned,
Yves