I've been reading the book CLR via C# by Jeffrey Richter and he argues that when defining a method in a base class, If there is a method you want to declare as virtual and it has a few convenience overloads, the most complex method should be the virtual method and the others should be left as non-virtual. Here is the example he gives:
public class Set {
private Int32 m_length = 0;
// This convenience overload is not virtual
public Int32 Find(Object value) {
return Find(value, 0, m_length);
}
// This convenience overload is not virtual
public Int32 Find(Object value, Int32 startIndex) {
return Find(value, startIndex, m_length - startIndex);
}
// The most feature-rich method is virtual and can be overridden
public virtual Int32 Find(Object value, Int32 startIndex, Int32 endIndex) {
// Actual implementation that can be overridden goes here...
}
// Other methods go here
}
What is the rational here?