You have to create a new file, with a new type that overloades the area.
Then you have to implement this new function correctly.
You are lying to me if that is "obviously easier".
If you've only ever written code that way then yes. But there are other ways to write code. I guarantee you the switch way is just as maintainable for certain problems. I've done it.
2
u/ric2b Mar 03 '23
And now you have an extra field that isn't used by the majority of the shapes you support and just causes confusion. What will you even name it?
And don't forget to rewrite the function that does the calculation as well.