I'm following somewhat of an Abstract Base Class pattern, that I use a lot in Python. This involves the use of a base class that offers a basic implementation and then can use subclasses to implement specific variations. For example
class Base {
function doWork() as Void {
doStep1();
doStep2();
}
function doStep1() as Void {
System.println("Base Class's Step 1"); // <--- Always prints, not the value that VariationA was initialized with
}
}
class VariationA extends Base {
function doStep1() as Void {
System.println("Variation A's Step 1");
}
}
instance = new VariationA().doWork(); // prints "Base Class's Step 1"
Since doStep1() is called from a method in the Base class, the version of the method in the Base class is always used, even on instances of VariationA. Is this expected/by design?