wi’m writing an online shop and while i was modelling the domain a question came to my mind, how to model objects that are changed from different systems with different granularity.
For e.g. let’s say we have a Product entity with some Attributes:
- Produtnumber
- Name
- Description
- Price
- etc.
We receive new products and product updates from two systems: an inventory management system (via webservice) and a management web ui integrated in the e-commerce product.
From the inventory management i always get a full update of the product with all attributes (even if not all changed). The management ui updates single attributes (crud).
So how should i model (and name) the business case related change methods on the product entity?
Somethin like updateFromIms(price, description, name, …) or should i write a setter for every attribute (which breaks the ‘unmodifiable’ entity)
When in doubt, I normally look at how the sample Shipping DDD application does it. The sample applicaiton in C# can be found: http://code.google.com/p/ndddsample/
So in your case, this is similar to how Cargo entity is treated, it has a constructor to create the entity, and then it has public methods like SpecifyNewRoute that is used by the BookingService to ChangeDestination or BookNewCargo. The BookingService is used by a BookingFacade that has the responsibility to:
So in your case, your UI and WebService could call a single facade method called UpdateProduct (I don’t think there is a conceptual difference between updating from a service or UI, so you don’t need a separate method like ChangeDestination but it’s your call). The facade methods will call into your ProductService::UpdateProduct method which will call into ProductModel::UpdateProduct
Now I don’t know the scope of your application, so this could be too much but DDD is not for small applications anyhow. Personally, I take Eric Evans’ book and NDD sample as a guidance but I don’t see a problem with getting rid of some of the complexity (ignoring the facade for example), no one knows your application better than you.