好的,基本问题,我是一名自学成才的开发人员,所以我似乎经常无法确定哪种方法是正确的方法......这就是其中之一!简单我有一个视图模型,其中包含一组子项。但是在定义这些类的地方我无法决定子对象是否应该是父对象的子类......
例如这个:
public class ActionChartViewModel
{
public IEnumerable<ActionChartItemViewModel> Items { get; set; }
public TextPagingInfo TextPagingInfo { get; set; }
}
public class ActionChartItemViewModel
{
public int Id { get; set; }
public string Name { get; set; }
public string Rating { get; set; }
public string Comment { get; set; }
public string AssignedToUserName { get; set; }
public string ContactRequested { get; set; }
public bool Resolved { get; set; }
public int NoteCount { get; set; }
public string ContactDetails { get; set; }
public int ResponseId { get; set; }
}
或这个:
public class ActionChartViewModel
{
public IEnumerable<Item> Items { get; set; }
public TextPagingInfo TextPagingInfo { get; set; }
public class Item
{
public int Id { get; set; }
public string Name { get; set; }
public string Rating { get; set; }
public string Comment { get; set; }
public string AssignedToUserName { get; set; }
public string ContactRequested { get; set; }
public bool Resolved { get; set; }
public int NoteCount { get; set; }
public string ContactDetails { get; set; }
public int ResponseId { get; set; }
}
}
我更喜欢第二个代码可读性和简单性,但我不知道子类的优缺点。大家会怎么想??
提前致谢!!