[Pharo-project] could we agree to remove caseOf: and caseOf:otherwise:
stephen.taylor at bom.gov.au
Mon Feb 14 23:17:11 CET 2011
Igor Stasenko wrote:
> On 14 February 2011 01:32, Schwab,Wilhelm K <bschwab at anest.ufl.edu> wrote:
>> That's where I typically use a dictionary.
Yes - sensible answer from Wilhelm Schwab.
>> You didn't answer the question though.
> Because it sounds rhetoric to me.
> How to deal with randomly put integers coming from outer source?
> If you're a software engineer, you should know it. :)
Indeed. Case construct is sometimes an appropriate way.
> - first try to avoid dealing with them. So if you can control the
> protocol, use other ways of encoding actions/data.
Yes, but the point is that one does not always have full control of ones
environment. Of course it would be nice it to have sensible input data.
It would be nice to have a pony with wings too.
> - organize these numbers (using dictionary or whatever), so they
> won't look like a random noise
> for people who first looking at your code. Put them into single place
> with documentation etc.
I do like the dictionary approach and sometimes do that. Other times I
wonder if I've made the world that much of a better place by loading the
logic into a dictionary rather than leaving it out in the code where
anyone can see it. It depends on the number of symbols.
I'm going to leave it here, as I don't want to find myself in the
position of the last and loudest advocate of case statements. I don't
think they're that good an idea in most circumstances, but I do think
they're reasonable enough sometimes.
More information about the Pharo-project