Simon Fell aptly points out that the structure of code that is based on using interfaces for extensibility

if(item is IWeblogItem){
IWeblogItem rssitem = (IWeblogItem) item;
string link = rssitem.Link;
/* do stuff */
}

if(item is IWeblogItem2){
IWeblogItem2 rssitem2 = (IWeblogItem2) item;
string commentsLink = rssitem2.CommentsLink;
/* do stuff */

}
is similar to that of code that uses XML for extensibility

if((node = item.SelectSingleNode("/rss:link", nsmanager))!= null){
string link = node.InnerText;
/* do stuff */
}

if(node = (item.SelectSingleNode("/rss:comments", nsmanager))!= null){
string commentsLink = node.InnerText;
/* do more stuff */
}


However there is a significant difference which is a consequence of the fact that data typically evolves faster than code. In the past few months significant changes to the RSS landscape have occured with the rise of RSS 2.0, replacement of content:encoded with xhtml:body by some notable RSS feeds and the invention of the CommentAPI. There would be significant API churn and information overload if a new interface was cooked up anytime something new happened in the RSS world and a news aggregator wanted to support this feature.

A user who wanted to use an updated plugin that handled recent addition to the metadata exposed by an RSS would need to update two applications instead of one. The RSS aggregator has to be updated to one that uses a new interface that exposes the new change in the RSS world and the plugin has to be updated to handle this new addition as well. These applications are tightly coupled. On the other hand, in a system where the aggregatot simply passed plugins the XML version of the RSS item as was provided in the feed then only the plugin has to be updated to take advantage of the new feature. Similarly the RSS aggregator can change its underlying implementation and how it represents RSS items in memory and as long as it still provides the plugin the XML from the feed as it always has done then changes in the underlying implementation of the aggregator are not visible to the plugin. This is a loosely coupled system.

I'm thirsty. I need some Bacardi Silver O3

 

Categories: