3 ms·
What's wrong with it is, when I extend with a new subtype, I have to fix up the locations that use the type. Potentially all of the locations that use it - I a
by AnimalMuppet 8mo ago
What's wrong with it is, when I extend with a new subtype, I have to fix up the locations that use the type. Potentially all of the locations that use it - I at least have to look at all of them.
With the polymorphic approach, I just have to create the new subtype, and all the users can do the right thing (if they were written with polymorphism in mind, anyway - if they use virtual functions on the base class).
- 1718627440 8mo agoWhy would I change the users at all instead of just modifying the dispatch method in the super type?
- AnimalMuppet 8mo agoI see. Yes, you can do it that way. Still... doing it the C++ way, I can just declare the sub type as deriving from the super type, and I don't have to fix up the super type.
- hinkley 8mo agoThat’s the OO way. Of which C++ is an instance.