[Prev][Next][Index][Thread]

Re: simple method dispatch question



"Michael Schuerig" <schuerig@acm.org> wrote in message
1ejwpfn.131ssh11hsll4wN%schuerig@acm.org">news:1ejwpfn.131ssh11hsll4wN%schuerig@acm.org...
>> This looks interesting, but it seems to me to obfuscate
>> semi-trivial (and very conventional) conditional logic
>> using the dispatch mechanism.  Doesn't this tend to make
>> write-only code outside of trivial examples?

> By the same argument you could replace polymorphism with
> conditional logic. -- I'm not sure whether I mean this as
> a reductio ad absurdum or as a serious consideration.

In my experience many people do actually use polymorphism (and other such
indirect mechanisms) in a manner which obfuscates program logic instead of
enhancing it.  Similarly many people use brain-mangling conditional logic
which obfuscates what's being done instead of making simple use of
appropriate indirect mechanisms to simplify the logic of the code.

As it stands, I withdraw my objection to Bruce's example anyway.  I tried it
out in a non-trivial program and, with a bit of careful code organisation,
found that I could enhance the readability of my code using his trick.

> What makes dispatch on singleton arguments attractive, in
> my view, is that extensions are unlikely to affect existing
> logic.

That's exactly what I found with my trial run using Bruce's trick -- with
the proviso that the relevant methods had to be placed in some kind of
rational order.





Follow-Ups: References: