Craig and MSDN Content Sets
Craig has an interesting post about his work on MSDN's content publishing architecture:
“...The problem is that, when content is coming into the system, it starts life as a lump of XML. But when the content is being rendered, it starts life as a database record. Further, there are some properties of the content set that are only present at render time, and some that are only present when the content is being loaded into the the database. We were torn whether to have something like this:
public class ContentSetBase { }
public class DbContentSet : ContentSetBase {
public DbContentSet() { }
}
public class XmlContentSet : ContentSetBase {
public XmlContentSet() { }
}
public class ContentSetFactory {
public DbContentSet CreateContentSetFromDatabase(db args) {}
public XmlContentSet CreateContentSetFromXml(xml args) {}
}or something like this:
public class ContentSetBase { }
public class DbContentSet : ContentSetBase {
public DbContentSet(db args) { }
}
public class XmlContentSet : ContentSetBase {
public XmlContentSet(xml args) { }
}...“
To me, the most logical thing to do in this situation is neither of these. Create a ContentSet entity class that is completely removed from the storage mechanism. Of course, Craig points out that they didn't do either of these, so maybe they did end up doing it the right way after all :-).
[1] http://staff.develop.com/candera/weblog2/CommentView.aspx?guid=edb4e430-f71e-4a6d-ac3a-dc2ac00bae22