Feb 26, 2022
Nice article!
IF and switches are a code smell as you pointed out
https://mcsee.medium.com/code-smell-36-switch-case-elseif-else-if-statements-73f0215abf2b
But the correct Solution (IMHO) is to use Polymorphism
Your solution violates Open/Closed Principle since we need to modify (not open) your method when a new animal arrives
Open for extension (new animal)
closed for modification (your method)
So. I will iterate it a bit further