I am still trying to workout separation of function and how it applies to class creation and namespace inclusion. I have a custom class SoftwareComponent which when presented to the user will most often appear as a ListItem. Is creating a ToListItem method a good idea? I worry because I have now placed a dependency in the class which will require the inclusion of the System.Web.UI.WebControls namespace.
public ListItem ToListItem()
{
ListItem li = new ListItem();
li.Text = ComponentName + " (+" + ComponentCost + ")";
li.Selected = Selected;
return li;
}
My other inclination is to create a ListItem from the SoftwareComponent based on its properties outside of the class itself. Please provide any thoughts on which approach is more appropriate/better.