3 ms·
Using static conditions rather than polymorphism seems to just be a common thing that people tend to do, regardless of skill level or quantity of experience. It
by to3m 14y ago
Using static conditions rather than polymorphism seems to just be a common thing that people tend to do, regardless of skill level or quantity of experience. It's not uncommon for people just not to think of using polymorphism, if the objects in question wouldn't really model any particular kind of object as such (they're just there to provide a table of function pointers). This says nothing about the quality of their code, or the general OOness of their designs, or the number of digits in their IQ.
It's a bit of a shame, because I've found code to be reliably improved by using objects as simple tables of function pointers. The same is less often true for using objects as models of things.
- geon 14y agoThat is strange to hear. That kind of polymorphism is literally the first example given in any OO tutorial. "Bark", "Meow", "Oink", etc.
- to3m 14y agoThe traditional animals/shapes/cars/etc. examples all use objects to represent actual things. But sometimes, one's objects don't reflect anything that you're trying to actually model. The need for them has just sort of arisen from the way the code has structured. They don't represent anything as such, they're just a way of putting in some extensible runtime dispatch. And it seems like people often prefer to use conditionals rather than objects for this situation. Not really sure why. Perhaps most people think of mere objectness as having some meaning, that makes using an object inappropriate for this kind of situation? I'm not sure. If you keep an eye out for this, I'm pretty sure you'll start to spot it!