java.netdomain-driven-designaggregateaggregators

When using Aggregate objects do you use custom collections for the associations or not?


For example is it better to have:

public class Case : EntityIdentifiable
{
    public Jobs Jobs { get; set; }
    public Vehicles Vehicles { get; set; }
    public Locations Locations {get;set;}

    public IDistances Distances { get; set; }
}

or

public class Case : EntityIdentifiable
{
    public Dictionary<string,Job> { get; set; }
    public Dictionary<string,Vehicle> { get; set; }
    public Dictionary<string,Location> {get;set;}

    public IDistances Distances { get; set; }
}

I know that I could have an IDictionary there instead as well, but I had thought this would be bit troublesome when persisting stuff. Or maybe I am just too tired of everything being abstract and allchanging all the time and want at least some fixed points somewhere.

At present I am not thinking forward enough to know if there will be much of functionality in the collection classes, but there may be a bit.

I also need to bear in mind that I plan to use NHibernate to store my objects.

What would you do ?


Solution

  • Use the simpler solution. If you discover later that you need more, refactor it.