c# - Newbie view model issue.. to subclass or not to subclass -
ok dead basic question, i'm self taught developer seem have gaps can't decide right way... , 1 of them!! simple have view model has collection of kid items. these classes defined can't decide if kid object should subclass of parent...
for illustration this:
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; } }
or this:
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; } } }
i prefer sec 1 code readability , simplicity front, don't know pros , cons of subclasses. guys think??
thanks in advance!!
i utilize separate classes (in same file) opposed inner class. inner class useful when serves parent class, i.e. not accessed outside of parent class, parent class methods, etc. in case inner class needs used on view(s), don't see need it. first option, i.e. separate classes, simpler me , reads better.
c# asp.net-mvc asp.net-mvc-3 asp.net-mvc-4
No comments:
Post a Comment