2 Comments
User's avatar
Denis Čahuk's avatar

No. Keep using the if-else chain or match.

This is not subtype polymorphism.

Subtype polymorphism requires differences of behavior. Your examples only have differences in data (the country's rate).

There is no difference in behavior in your examples.

A better example would be using a static table for Country -> Rate where calculations are simple and use the same function to calculate _income * rate_

Expand full comment
Dave Liu's avatar

OOP is a damn plague. Constantly misused, and a quintessential example of over-engineering. This is why Python is the most popular language.

Expand full comment