Dynamic Dispatch is Control Flow
In 2010, I saw a tweet that changed how I think about programming. I do not remember who tweeted it, and I have been unable to locate it again, but its gist was “The Tao of OOP is that dynamic dispatch is control flow”.
This is true, and it creates an entirely different way of thinking about designing objects. I also find it applies somewhat to functional programming.
Let’s start with a small, contrived example:
if (shape.isFilled()) {
fillAndStroke(shape);
else {
} stroke(shape);
}