DDD Custom properties by dynamic composition of a document/entity
03:33 29 Mar 2017

We're refactoring our solution to a Domain Driven Design structure. Our consultants which implement the software, should be able to customize some behavior of the application (for specific customers needs). For example they want to add custom defined properties to the presentation (user input forms) and save the custom data together with the entities defined in our DDD projects.

However, the domain objects should preferably not contain a customData property. I don't want to mix those and let the domain object know that there's something like custom data. I'm saving en fetching the entities by Repositories.

How do I make this scenario possible? One possible solution would be:

  • Query the entity by using his Repository
  • And query separately the CustomPropertiesRepository by entity ID.
  • Combine the two queries objects.
  • When saving the forms. It will be splitted again using two repositories

The disadvantage of this, is that I have to query twice though it should be one document.

Any advice on this problem?

domain-driven-design ddd-repositories