Jon Skeet said:
Microsoft's guidelines disagree with you
Its not the only one I disagree with.
Guidelines are just that, guidelines.
In fact I dont use privates at all - I realize this is heresy to many but we do a lot of inheriting
within our own frameworks and too often I've inherited someone elses object and very few
developers understand when to make something private and when to make it protected - and those
that do rarely sit and think about each declaration. Too often things that are private should be
protected (Fields, methods, properties). If its all protected - it can be inherited from. If you dont
intend your class to be inherited from, seal it.
"Do not use instance fields that are public or protected (Public or
Protected in Visual Basic). If you avoid exposing fields directly to
the developer, classes can be versioned more easily because a field
cannot be changed to a property while maintaining binary
compatibility."
The part they dont state is that doing so in many cases adds significant overhead, and if the
developer really doesnt undersand what they are doing and blindly follows this then those
inheriting from their class will have real problems.
Such advice is fine for final classes, but if its intended to be inherited from its bad advice to be
followed as a rule.
If you look at type datasets, or troll around with reflector you will see that in some cases
Microsoft does not follow consistent guildelins themselves, and certainly when they do they
are not using the same ones they have published for others. I suspect that those that published
these guidelines are different and simply provided some basic starts and tips for others since
many users do not know where to start.
--
Chad Z. Hower (a.k.a. Kudzu) -
http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
Develop ASP.NET applications easier and in less time:
http://www.atozed.com/IntraWeb/