I frequently find myself creating classes which use this form (A):
abstract class Animal {
public void Walk() {
// TODO: do something before walking
/
For a method that provides a template method's primary behavior, I use names like WalkOverride
. The base class implements it as either a protected abstract
method (derived class is required to provide implementation) or a protected virtual
empty/non-empty one (derived class may optionally provide/override implementation). Examples can be found in Microsoft's various XAML frameworks with methods such as MeasureOverride
and ArrangeOverride
. (The WalkCore
pattern @Jehof mentions is used there to name the template method itself.)
For "events" to which the derived class can optionally respond for its own purposes (as opposed to defining the template method's behavior), I use names like OnWalking
and OnWalked
. Each of these is usually implemented in the base class as a protected virtual
method with an empty method body.