As per this question, while I understand why it goes wrong, how can I effectively solve this while keeping my code DRY? I wouldn't want to copy and paste the contents in that function into the constructor.
Suppose I have the following
class Parent
{
Parent()
{
overridableFunction();
}
void overridableFunction()
{ ... }
}
class Child extends Parent
{
Child()
{
super();
overridableFunction()
}
void overridableFunction()
{ ... // overridden }
}
Ideally, I wish the execution flow of the Child
constructor to be
Parent() --> Parent.overridableFunction() --> Child.overridableFunction()
How can I achieve this without copying and pasting stuff around thus making the code WET?