PRE-PROPOSAL: Named method parameters with defaults.

Reinier Zwitserloot reinier at zwitserloot.com
Sun Mar 22 17:47:09 PDT 2009


If your goal is to find a way to eliminate the builder pattern - good  
luck. I don't think any proposal other than the builder pattern can  
replace the builder pattern. Even python and friends have rare usage  
of the builder pattern.

This proposal has named parameters, defaults, and allows shuffling  
order. What more could you possibly  want out of a proposal to make  
direct method invocation easier when there are many parameters?

  --Reinier Zwitserloot



On Mar 23, 2009, at 01:07, Marek Kozieł wrote:

> 2009/3/23 Reinier Zwitserloot <reinier at zwitserloot.com>:
> [snip]
>> 3. [Builder pattern still needed because of order] But you CAN  
>> change the
>> order.
>>
>>  --Reinier Zwitserloot
>
> Yes i know.
> But functionality of this solution is limited, while interactions  
> are huge.
> If you will need give all for example 9 parameters, you will still
> need to check if you didn't omitted any, this mean more text for
> analyse.
>
> In this code you can ignore some parameter if you need:
>   class SomeBuilder{
>      SomeBuilder setA(A a){...};
>      SomeBuilder setB(B a){...};
>      ...
>   }
>
> call:
>      new Some( new SomeBuilder().setA(a).setB(b)... );
>
> When there is a lot parameters soon or later you will need builder
> (more or less).
>
> What more when happen that you will want obtain A & B & C from some
> new created object D:
> All modification for builder will be adding method:
>   SomeBuilder setABC(D d){...};
> , while in given solution you will need copy & paste constructor and  
> modify it.
>
> -- 
> Pozdrowionka. / Regards.
> Lasu aka Marek Kozieł
>
> http://lasu2string.blogspot.com/




More information about the coin-dev mailing list