

When Polymorphism Fails   - yarapavan
http://steve.yegge.googlepages.com/when-polymorphism-fails

======
thwarted
_You get the easy part: you need to decide what classes Willie is to construct
the tree with._ ... _I won't give away the answer, but a Standard Bad Solution
involves the use of a switch or case statment (or just good old-fashioned
cascaded-ifs). A Slightly Better Solution involves using a table of function
pointers, and the Probably Best Solution involves using polymorphism._

If the requirement was to show which _classes_ should be used and the result
is a series of conditionals or function pointers (even if they are wrapped in
a single "operator" class), I'd say the requirements _have not_ been met. To
me, "classes" implies doing it with a class hierarchy or polymorphism.

------
jsteele
That example of coding an elfLikesMe attribute for 150 monster types, why to
code it at all? My first hunch would be to use SQL table for monster
attributes, then adding new attribute would be equivalent to adding a new SQL
field, or table?

