I would possibly not suggest the "proper" solution you presented was any more "proper" than a fairly extensive if chain. It opens up plenty of issues of it's own because of typing and data ranges.
You do have a point on the if statement being a good potential for new programmer mess-ups, but simply it's not really "over-complicating" as inappropriate use.
It goes for all languages features, use where it seems most appropriate. This is hard for new programmers to nail, because they need to learn this by experience by and large.
Ironically if statements stop being appropriate at many path branches, yet hold their own at complex expression branching. Typically most complexity can be abstracted away by a good object (read:datum, obj, mob whatever works for the given data) model, including mitigating issues with types and data ranges a la your call() solution. |
|