Abstract Base Classes and Interfaces

Phil Haack, who is working on the ASP.NET MVC project at Microsoft, posted an explanation of the choice they made to change the abstraction of HTTPContext from an interface to an abstract base class.

This topic is something I like to ask about in interviews for more senior developers who are expected to take on design work as well as development.  The answer I generally look for is something along the lines of:

Abstract base classes should be used in cases where the actual behavior is significant to the contract.

Phil goes in to much more depth here and discusses something that is also very important:  the choice between interfaces and abstract base classes is a crucial component to flexibility when it comes to versioning.

Read Phil’s post on this.  It is a good explanation of the tradeoffs involved.



Comments are closed.