Faced with the prospect of mapping a dozen or so cases defined by half a dozen attributes on to two or three actions which just set flags or scalars, I thought that, rather than tacking more ifs and elses onto the existing code, it might be a good idea to use a hash. I would have to convert relevant combinations of attributes into a form that I could use as a hash key and the corresponding values for the resulting actions into a hash value.
Has anyone used this approach before and knows of any caveats? Or does anyone have a better idea? I should say that I shall actually be implementing this in Java, so I won't be able to make use of any particularly Perly solutions, although I would still be insterested in them.
Thanks,
In reply to Avoiding if/else knots by loris
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |