What I want from an ORM
Thought I'd blog about some of the things I'd like to see in an ORM in the future, particularly to support DDD cleanly:
- No enforced associations - I never want to create an association in the model just to support persistence, regardless of where keys are stored. So if I want to use uni-directional associations then I should be able to do that without having to go for workarounds.
- Aggregate locking - Currently, with NHibernate at least, its difficult to lock an entire aggregate. For example NHibernate's optimistic concurrency approach involves applying a version to rows, however aggregates can span tables so we really want to be able to give each aggregate a shared version (coarse-grained locking approach). See coarse-grained lock pattern.
- Validating before saving - I'd like hooks to automatically and cleanly validate an entire aggregate before persistence.
- Disabling unit of work - I'd like to be able to disable my unit of work, in many cases when working with DDD the UOW becomes more of a hindrance than anything else. I really want to be 100% sure that the only way to save a Customer is through a CustomerRepository.
- Revalidate value objects when reloading - Value objects only validate their data in their constructors, if your ORM does not ensure that a constructor that performs the validation is also used when reloading the object then its possible to end up with an invalid Value object. This is something you definitely want to avoid. Greg Young has raised this issue a few times, including in the NHibernate forum, and made some very good points.
- Value objects - Choosing to view something as a value object is a design decision that you make irrespective of the underlying DB design, so whilst the NHibernate component mapping is useful it should be as powerful as the mappings used elsewhere. Unfortunately with NHibernate components don't support inheritance nicely and if your value object is stored in a separate table things get confusing.
There may be other things I'd want but those are the ones that come to mind.
Mate you were totally spot on with those assertions....Only thing I can think you left out was, be 34-24-36. be always willing and fry up some nice eggs and hash browns in goose fat at 3 am after I've had a few at 3:30 am...
ReplyDeleteHowever fact remains. EoF from next is still the original and best....