I've built a rich domain model for a private app I'm working on, it feels right, it got the correct mix of business functionality and models the domain problem very well, it even has flexibility for the future. I consciously had to keep focusing the domain expert and myself on the current iteration and not the future!
So I reached a point where I want to expose a 'view' depending on the 'context' of usage.
Simply put I want to expose data from some of the entitles as a 'catalog'. This catalog is immutable - the users of the catalog can't change or modify the contents they can only 'view' what is available. Items in the catalog don't contain an entity identifier and they only contain a subset of an entities data. This catalog item is starting to sound like a value object to me...
So the question is; Can I create a value object from an entity?
I think it's perfectly acceptable to do this - remember a value object should be immutable, the sub-text of the question for me is; is it acceptable to expose value objects via a service? I want a service that allows searching & returning of catalog items (with pagination etc). I also think this perfectly acceptable approach.
I suppose what I've defined here is a 'context' boundary for the core domain model - 'bounded context'.
Awkward Coder
So I reached a point where I want to expose a 'view' depending on the 'context' of usage.
Simply put I want to expose data from some of the entitles as a 'catalog'. This catalog is immutable - the users of the catalog can't change or modify the contents they can only 'view' what is available. Items in the catalog don't contain an entity identifier and they only contain a subset of an entities data. This catalog item is starting to sound like a value object to me...
So the question is; Can I create a value object from an entity?
I think it's perfectly acceptable to do this - remember a value object should be immutable, the sub-text of the question for me is; is it acceptable to expose value objects via a service? I want a service that allows searching & returning of catalog items (with pagination etc). I also think this perfectly acceptable approach.
I suppose what I've defined here is a 'context' boundary for the core domain model - 'bounded context'.
Awkward Coder
Comments
Post a Comment