使用聚合对象时,是否使用自定义集合进行关联?
例如,最好有:
public class Case : EntityIdentifiable
{
public Jobs Jobs { get; set; }
public Vehicles Vehicles { get; set; }
public Locations Locations {get;set;}
public IDistances Distances { get; set; }
}
或者
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; }
}
我知道我也可以在那里有一个 IDictionary,但我认为这在持久化东西时会有点麻烦。或者也许我只是厌倦了一切都是抽象的并且一直在变化,并且想要至少在某个地方有一些固定点。
目前,我的思考不够深入,无法知道集合类中是否会有很多功能,但可能会有一点。
我还需要记住,我计划使用 NHibernate 来存储我的对象。
你会怎么办 ?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用更简单的解决方案。如果您后来发现需要更多,请重构它。
Use the simpler solution. If you discover later that you need more, refactor it.