Timeline for Is it still a code smell if a class knows all subtypes but not using instanceof and downcasting?
Current License: CC BY-SA 4.0
3 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 28 at 16:20 | comment | added | Basilevs | @andrewf there is some structure, if you assume that each tool have only one stat. They could then split into Weapon, Armor, Arcane and Visitor would be applicable. Also this example extends the original scope, making it more interesting/flexible. | |
| Mar 28 at 15:58 | comment | added | andrewf | You don’t want the Visitor pattern, because the abstraction (that we’re concerned about here) is not the collection of tools, but the effect of each tool itself. So (as other answers suggest), if we’re using polymorphism, it’s up to each subclass to say how much it affects speed, defence, attack, etc. Visitor pattern would be for when we’re generalising over the structure of the collection of (tools). | |
| Mar 28 at 13:15 | history | answered | Kain0_0 | CC BY-SA 4.0 |