There was a lot of discussion and feedback from my previous post about sealed classes. My good friend Steve Borg questioned what the sealed class count would be if I extended my search. Thanks to Reflector and Reflector.FileDisassembler I was able to get a count of all public sealed classes in main part .NET 2.0 (v2.0.50727 final downloaded from Microsoft). The previous count was also only the beta of .Net 2.0. This is a listing of the main parts of the framework, broken down by namespace. Sealed is classes marked as "public sealed class" and open is classes marked as "public class".
- mscorlib: 60% Sealed
- Sealed: 385
- Open: 249
- System: 30% Sealed
- Sealed: 167
- Open: 390
- System.Data: 69% Sealed
- Sealed: 120
- Open: 53
- System.Drawing: 53% Sealed
- Sealed: 62
- Open: 54
- System.Web: 49% Sealed
- Sealed: 353
- Open: 364
- System.Windows.Forms: 14% Sealed
- Sealed: 84
- Open: 499
- System.Xml: 13% Sealed
- Sealed: 22
- Open: 147
- Total: 40% Sealed
- Sealed: 1193
- Open: 1786
System.Data is the worst culprit with 69% of public classes being sealed. System.Xml is the most open to extensibility with only 13% sealed.
I also ran Security and got:
- Security: 59% Sealed
- Sealed: 40
- Open: 27
But I didn't include it in the above stats for two reasons:
- Security is sealed for a different, although questionable in my opinion, reason.
- I don't consider it part of the main part of the framework.
Verdict: Even with the relatively open and large System.Windows.Forms and System.Xml the .Net framework is still close to half sealed. Now where I can see Sealed may have its place, I still think Microsoft over used it in the .Net framework. If they were really concerned about user extensibility they would have created an unsealed version of most classes.
Subject Tags: [Programming] [Software] [Development] [Reflector] [FileDisassembler] [dotnet] [dotnet2.0] [Microsoft] [Sealed] [Sealed Class] [OOP] [Framework]
No comments:
Post a Comment