Visual C# Best Practices
* Use abstract classes and interfaces in combination to optimize your design trade-offs.
Use an abstract class
* When creating a class library which will be widely distributed or reused—especially to clients, use an abstract class in preference to an interface; because, it simplifies versioning. This is the practice used by the Microsoft team which developed the Base Class Library. (COM was designed around interfaces.)
* Use an abstract class to define a common base class for a family of types.
* Use an abstract class to provide default behavior.
* Subclass only a base class in a hierarchy to which the class logically belongs.
Use an interface
* When creating a standalone project which can be changed at will, use an interface in preference to an abstract class; because, it offers more design flexibility.
* Use interfaces to introduce polymorphic behavior without subclassing and to model multiple inheritance—allowing a specific type to support numerous behaviors.
* Use an interface to design a polymorphic hierarchy for value types.
* Use an interface when an immutable contract is really intended.
* A well-designed interface does only one thing—not a potpourri of functionality.
The more I read, the more I acquire, the more certain I am that I know nothing. -Voltaire
Subscribe to:
Post Comments (Atom)
Ramadan - What is it?
Ramadan is one of the most important and holy months in the Islamic calendar. It is a time of fasting, prayer, and spiritual reflection fo...
-
ZipStudio - A versatile Visual Studio add-in to zip up Visual Studio solutions and projects - The Code Project - C# Programming
-
TargetProcess - Agile Project Management & Bug Tracking Software | Download (Project Management Software, Project Tracking, Bug Tracking...
No comments:
Post a Comment