Re: Keyword Arguments

Kevin Edwards <[email protected]> Thu, 14 Jun 2012 12:52:49 -0500
Newsgroups gmane.comp.lang.io
Message-ID <[email protected]>
On 6/13/2012 3:08 PM, Steve Dekorte wrote:
> As objects are about coupling data and logic, if you're passing a 
> lot of arguments(data) around
> to methods (logic), then it looks suspiciously like you've failed 
> to couple your data and logic.
>
> If I were to take the position that all uses of multiple arguments 
> (and therefore keyword arguments)
> are failures to use proper OO design, could you provide a counter 
> example?
>
> For example, in this:
>
>>     def render(view, formats = ["html"], cache = false)
>
> formats and cache seem like natural instance variables of the 
> receiver.

It can be suspicious to have a lot of args, but perhaps arity is not 
the best metric to use since you can just repackage the args, as you 
seem to be suggesting.  Every 2+ argument method call can be 
rewritten as a series of 1 argument method calls which configures 
the object/frame.  e.g. :

   meth(a=1, b=2, c=3) <->  Meth clone setA(1) setB(2) setC(3) result

Both versions can have the same massive, monolithic implementation 
of logic with just a difference in packaging.

Is the RHS better than the LHS?  Is `setA(1)` with the slot name "A" 
curried into the message name better than the orthogonal triadic 
assignment function `a = 1`?  Why aren't they equivalent in Io?

Kevin