Inheritance best practice: test Type of subclass or use enum?
See attched UML. Just wondering what the best practice is? Is it better to test the Type of BaseEffect in code:
or to use an enum as per the UML:
2 Replies
I'd use pattern matching. You would have to cast the base class to the child class anyway, and pattern matching does it for you.
Just read the microsoft pattern matching article and I'm sold! All makes the code super readable and nicely compact (aside from the arbitrary "_" as a discard token)
Thanks