views:

145

answers:

1

How would you organize an entity that has 100s of properties? One could go as far to say 100s of properties, with a few Value Objects (as a few of the properties have 2 or 3 properties of their own). But the point is, how to handle the large number of properties.

I am re-creating our model from the ground-up using DDD, and the current issue is how to organize one of main entities that is broken up into many many many subsets. Currently it was written to have about a dozen sub-sets of properties. Like CarInfo() with 50+ properties, CarRankings() with 80+, CarStats(), CarColor(), etc, etc.

Think of it as mass-data stored on a single entity root.

Is it appropriate to have a service for the simple purpose of grouping a large collection of properties? Like CarInfoService that would return a Car() object, along with a large collection or sort.

Another idea would be to look at how the data is displayed. There is no one view that shows all of this data. Instead, they are split up based on their subjective matter. Like CarInfo shows all information about the car. Another would be CarStats that shows all stats of the car. So in this sense, the Application layer can build the underlying details needed for the UI. But, I still need a way to store it in the domain.

I have a mind to just put a number of xml property bags on it and call in the day. lol

+1  A: 

This is a tough problem. You've got an aggregate root with lots of branches. But it sounds as if your users only work with certain collections at certain times. You could try pruning the tree a bit.

For instance, in your Car example, if your users are comparing the rankings of different cars, you could treat that as its own module or subsystem. No need to load up the detailed car data associated with each ranking, if the specific task is to figure out which ones rate better than others.

Remember, even though the data may be stored in a parent-child hierarchy in the database, it doesn't necessarily mean your domain will be structured in the same way.

By looking at the tasks or functions your users will perform on your data, you might discover concepts that help to break up that giant aggregate into more manageable chunks.

If you do need to assemble the full root with all of its branches, I think you'll definitely want some sort of service to bring everything together.

dthrasher
I agree that a service is the only way to bring all of these collections together on the aggregate root. I ended up grouping the properties into chunks, called Collections. So, it would be CarInfoCollection, CarRankingCollection, etc. And, it is stored as Xml property bags as the properties expands and contracts over time.
eduncan911
I'm glad you found an approach that worked for your situation. Handling items with many, many properties is tough. When I worked on real estate systems, we had to deal with similar problems all the time.
dthrasher
What if there isn't approach that works out? I have similar situation and i'm sure that aggregate can't be divided. Imagine - stuffing html document object model in objects. For me it seems that DDD just does not fit here.
Arnis L.