March 2004
Intermediate to advanced
560 pages
26h 47m
English
public interface IComparable { // Methods int CompareTo (object obj); }
|
BA There is a natural tension between modeling a concept as an interface and as a base class. In this case it is clear that requiring developers to inherit from a Comparable base class to be comparable would have been too restrictive. However, this class does illustrate good design principles for any interface. It is simple; there are no complex contracts to be maintained between the members of the interface (because there is only one member). The concept is clearly an additive element of the class design rather than the center point of the design. JR When defining a value type that implements IComparable, you should define a type-safe version of the method ... |
Read now
Unlock full access