24 Jul
2008

Refactoring the .Net Framework

Category:General PostTag: , :

What possible reason could there be for sealing the System.IO.File class? A sealed class means I must wrap the class just to have my own functionality, rather than extending it. Further, it becomes significantly painful to mock the class in unit tests without an interface.

Granted, Microsoft is doing mucho better these days, and I doubt this decision would be made today if they were re-releasing the framework. So why not go in there and unseal things like this as a service pack? Look at what the ASP.Net team has done for IHttpContext as an example. Good stuff.

I know I am not the first or last person to rant about these things, but here’s my question. Why can’t these refactorings be released into subsequent versions of the framework?

The “Extract Interface” refactoring is a pretty easy one.

5 thoughts on “Refactoring the .Net Framework

  1. Just a thought as to why it hasn’t been changed … It can’t be “easily” changed in a service pack.

    System.IO.File is a class that is covered by the ECMA specification for the BCL. There aren’t a ton of classes in the spec but it is one of them. A change to it would require an update to the spec which is not a trivial manner (I can only imagine the red tape surrounding that one).

    Cheers,

    Greg

Comments are closed.