You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@click.apache.org by Bob Schellink <sa...@gmail.com> on 2009/06/25 19:19:35 UTC

Method chaining revisited

Its been suggested before to add method chaining to Click controls.

With Java5 support of Covariant return types, I'd like to revisit this 
feature. It would allow us to write the following:

   form.add(new TextField("name").required(true).width("200px"));

instead of:

   TextField field = new TextField("name");
   field.setRequired(true);
   field.setWidth("200px");
   form.add(field);


I think Field and Column would get the most benefit from such a change.

Couple of issues are API bloat, which is why I'd like to limit this to 
  only a couple of controls. The other issue is NPE but that shouldn't 
be a problem because a reference to the Control instance is always 
returned.

Thoughts?

bob

Re: Method chaining revisited

Posted by Malcolm Edgar <ma...@gmail.com>.
:)

I am actually coming around to the builder pattern, previously I have
used the factory pattern. I would like to try it on a project to get a
better feel for its use.

regards Malcolm Edgar

On Mon, Jul 6, 2009 at 11:04 PM,
contactme42@gmail.com<co...@gmail.com> wrote:
> Malcolm,
>
> Please make it harder so that we should need to do at least 10% of the work
> :-) I don't want to get any lazier then I am already.
>
> Joking aside, that sounds great then.
>
> Regards,
>
> Huy
>>
>> Agree, but I think this is how people would probably use it. The
>> TableBuilder and FormBuilder would have 95% of the code you would need
>> and then you would subclass it to provide that last 5% for your work.
>>
>> regards Malcolm Edgar
>>
>> On Sat, Jul 4, 2009 at 1:35 PM,
>> contactme42@gmail.com<co...@gmail.com> wrote:
>>
>>>
>>> Yeah builders/factories are great for building click forms/tables, but I
>>> find writing my own much more flexible because I always tend to customize
>>> the objects created.
>>>
>>> Huy
>>>
>>>>
>>>> Hi Malcolm,
>>>>
>>>> This looks awesome. Definitely makes for good examples.
>>>>
>>>> regards
>>>>
>>>> bob
>>>>
>>>>
>>>> Malcolm Edgar wrote:
>>>>
>>>>>
>>>>> Please see the JIRA below:
>>>>>
>>>>> http://issues.apache.org/jira/browse/CLK-565
>>>>>
>>>>> This provides two example patterns. I think it would be good to
>>>>> include something like this in click extras.
>>>>>
>>>>> regards Malcolm Edgar
>>>>>
>>>>> On Fri, Jul 3, 2009 at 3:11 AM, Adrian A.<a....@gmail.com>
>>>>> wrote:
>>>>>
>>>>>>>
>>>>>>> This is a topic I wanted to raise for 2.2 is introducing a
>>>>>>> builder/factory capability in Click.  We have used this in projects
>>>>>>> and it greatly number of lines of code. Personally I think this is a
>>>>>>> better approach than method chaining.
>>>>>>>
>>>>>>
>>>>>> +1 for this (instead of method chaining). The same for other
>>>>>> frequently
>>>>>> used
>>>>>> APIs.
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> I
>>>>>>> will u pload some builder/factory patterns later today.
>>>>>>>
>>>>>>
>>>>>> Any news on this?
>>>>>>
>>>>>> Thank you,
>>>>>>
>>>>>> Adrian.
>>>>>>
>>>>>>
>>>>>>
>>>
>>>
>
>

Re: Method chaining revisited

Posted by "contactme42@gmail.com" <co...@gmail.com>.
Malcolm,

Please make it harder so that we should need to do at least 10% of the 
work :-) I don't want to get any lazier then I am already.

Joking aside, that sounds great then.

Regards,

Huy
> Agree, but I think this is how people would probably use it. The
> TableBuilder and FormBuilder would have 95% of the code you would need
> and then you would subclass it to provide that last 5% for your work.
>
> regards Malcolm Edgar
>
> On Sat, Jul 4, 2009 at 1:35 PM,
> contactme42@gmail.com<co...@gmail.com> wrote:
>   
>> Yeah builders/factories are great for building click forms/tables, but I
>> find writing my own much more flexible because I always tend to customize
>> the objects created.
>>
>> Huy
>>     
>>> Hi Malcolm,
>>>
>>> This looks awesome. Definitely makes for good examples.
>>>
>>> regards
>>>
>>> bob
>>>
>>>
>>> Malcolm Edgar wrote:
>>>       
>>>> Please see the JIRA below:
>>>>
>>>> http://issues.apache.org/jira/browse/CLK-565
>>>>
>>>> This provides two example patterns. I think it would be good to
>>>> include something like this in click extras.
>>>>
>>>> regards Malcolm Edgar
>>>>
>>>> On Fri, Jul 3, 2009 at 3:11 AM, Adrian A.<a....@gmail.com> wrote:
>>>>         
>>>>>> This is a topic I wanted to raise for 2.2 is introducing a
>>>>>> builder/factory capability in Click.  We have used this in projects
>>>>>> and it greatly number of lines of code. Personally I think this is a
>>>>>> better approach than method chaining.
>>>>>>             
>>>>> +1 for this (instead of method chaining). The same for other frequently
>>>>> used
>>>>> APIs.
>>>>>
>>>>>           
>>>>>> I
>>>>>> will u pload some builder/factory patterns later today.
>>>>>>             
>>>>> Any news on this?
>>>>>
>>>>> Thank you,
>>>>>
>>>>> Adrian.
>>>>>
>>>>>
>>>>>           
>>     


Re: Method chaining revisited

Posted by Malcolm Edgar <ma...@gmail.com>.
Agree, but I think this is how people would probably use it. The
TableBuilder and FormBuilder would have 95% of the code you would need
and then you would subclass it to provide that last 5% for your work.

regards Malcolm Edgar

On Sat, Jul 4, 2009 at 1:35 PM,
contactme42@gmail.com<co...@gmail.com> wrote:
> Yeah builders/factories are great for building click forms/tables, but I
> find writing my own much more flexible because I always tend to customize
> the objects created.
>
> Huy
>>
>> Hi Malcolm,
>>
>> This looks awesome. Definitely makes for good examples.
>>
>> regards
>>
>> bob
>>
>>
>> Malcolm Edgar wrote:
>>>
>>> Please see the JIRA below:
>>>
>>> http://issues.apache.org/jira/browse/CLK-565
>>>
>>> This provides two example patterns. I think it would be good to
>>> include something like this in click extras.
>>>
>>> regards Malcolm Edgar
>>>
>>> On Fri, Jul 3, 2009 at 3:11 AM, Adrian A.<a....@gmail.com> wrote:
>>>>>
>>>>> This is a topic I wanted to raise for 2.2 is introducing a
>>>>> builder/factory capability in Click.  We have used this in projects
>>>>> and it greatly number of lines of code. Personally I think this is a
>>>>> better approach than method chaining.
>>>>
>>>> +1 for this (instead of method chaining). The same for other frequently
>>>> used
>>>> APIs.
>>>>
>>>>> I
>>>>> will u pload some builder/factory patterns later today.
>>>>
>>>> Any news on this?
>>>>
>>>> Thank you,
>>>>
>>>> Adrian.
>>>>
>>>>
>>>
>>
>
>

Re: Method chaining revisited

Posted by "contactme42@gmail.com" <co...@gmail.com>.
Yeah builders/factories are great for building click forms/tables, but I 
find writing my own much more flexible because I always tend to 
customize the objects created.

Huy
> Hi Malcolm,
>
> This looks awesome. Definitely makes for good examples.
>
> regards
>
> bob
>
>
> Malcolm Edgar wrote:
>> Please see the JIRA below:
>>
>> http://issues.apache.org/jira/browse/CLK-565
>>
>> This provides two example patterns. I think it would be good to
>> include something like this in click extras.
>>
>> regards Malcolm Edgar
>>
>> On Fri, Jul 3, 2009 at 3:11 AM, Adrian A.<a....@gmail.com> 
>> wrote:
>>>> This is a topic I wanted to raise for 2.2 is introducing a
>>>> builder/factory capability in Click.  We have used this in projects
>>>> and it greatly number of lines of code. Personally I think this is a
>>>> better approach than method chaining.
>>> +1 for this (instead of method chaining). The same for other 
>>> frequently used
>>> APIs.
>>>
>>>> I
>>>> will u pload some builder/factory patterns later today.
>>> Any news on this?
>>>
>>> Thank you,
>>>
>>> Adrian.
>>>
>>>
>>
>


Re: Method chaining revisited

Posted by Bob Schellink <sa...@gmail.com>.
Hi Malcolm,

This looks awesome. Definitely makes for good examples.

regards

bob


Malcolm Edgar wrote:
> Please see the JIRA below:
> 
> http://issues.apache.org/jira/browse/CLK-565
> 
> This provides two example patterns. I think it would be good to
> include something like this in click extras.
> 
> regards Malcolm Edgar
> 
> On Fri, Jul 3, 2009 at 3:11 AM, Adrian A.<a....@gmail.com> wrote:
>>> This is a topic I wanted to raise for 2.2 is introducing a
>>> builder/factory capability in Click.  We have used this in projects
>>> and it greatly number of lines of code. Personally I think this is a
>>> better approach than method chaining.
>> +1 for this (instead of method chaining). The same for other frequently used
>> APIs.
>>
>>> I
>>> will u pload some builder/factory patterns later today.
>> Any news on this?
>>
>> Thank you,
>>
>> Adrian.
>>
>>
> 


Re: Method chaining revisited

Posted by Malcolm Edgar <ma...@gmail.com>.
Please see the JIRA below:

http://issues.apache.org/jira/browse/CLK-565

This provides two example patterns. I think it would be good to
include something like this in click extras.

regards Malcolm Edgar

On Fri, Jul 3, 2009 at 3:11 AM, Adrian A.<a....@gmail.com> wrote:
>> This is a topic I wanted to raise for 2.2 is introducing a
>> builder/factory capability in Click.  We have used this in projects
>> and it greatly number of lines of code. Personally I think this is a
>> better approach than method chaining.
>
> +1 for this (instead of method chaining). The same for other frequently used
> APIs.
>
>> I
>> will u pload some builder/factory patterns later today.
>
> Any news on this?
>
> Thank you,
>
> Adrian.
>
>

Re: Method chaining revisited

Posted by "Adrian A." <a....@gmail.com>.
> This is a topic I wanted to raise for 2.2 is introducing a
> builder/factory capability in Click.  We have used this in projects
> and it greatly number of lines of code. 
> Personally I think this is a better approach than method chaining.  
+1 for this (instead of method chaining). The same for other frequently 
used APIs.

> I
> will u pload some builder/factory patterns later today.
Any news on this?

Thank you,

Adrian.


Re: Method chaining revisited

Posted by Malcolm Edgar <ma...@gmail.com>.
This is a topic I wanted to raise for 2.2 is introducing a
builder/factory capability in Click.  We have used this in projects
and it greatly number of lines of code.

Personally I think this is a better approach than method chaining.  I
will u pload some builder/factory patterns later today.

regards Malcolm Edgar

On Fri, Jun 26, 2009 at 2:07 PM, florin.g<fl...@bytenotes.com> wrote:
>
> I'm a fan
>
>
>
> sabob wrote:
>>
>> Its been suggested before to add method chaining to Click controls.
>>
>> With Java5 support of Covariant return types, I'd like to revisit this
>> feature. It would allow us to write the following:
>>
>>    form.add(new TextField("name").required(true).width("200px"));
>>
>> instead of:
>>
>>    TextField field = new TextField("name");
>>    field.setRequired(true);
>>    field.setWidth("200px");
>>    form.add(field);
>>
>>
>> I think Field and Column would get the most benefit from such a change.
>>
>> Couple of issues are API bloat, which is why I'd like to limit this to
>>   only a couple of controls. The other issue is NPE but that shouldn't
>> be a problem because a reference to the Control instance is always
>> returned.
>>
>> Thoughts?
>>
>> bob
>>
>>
>
> --
> View this message in context: http://n2.nabble.com/Method-chaining-revisited-tp3156429p3159580.html
> Sent from the click-development mailing list archive at Nabble.com.
>
>

Re: Method chaining revisited

Posted by "florin.g" <fl...@bytenotes.com>.
I'm a fan



sabob wrote:
> 
> Its been suggested before to add method chaining to Click controls.
> 
> With Java5 support of Covariant return types, I'd like to revisit this 
> feature. It would allow us to write the following:
> 
>    form.add(new TextField("name").required(true).width("200px"));
> 
> instead of:
> 
>    TextField field = new TextField("name");
>    field.setRequired(true);
>    field.setWidth("200px");
>    form.add(field);
> 
> 
> I think Field and Column would get the most benefit from such a change.
> 
> Couple of issues are API bloat, which is why I'd like to limit this to 
>   only a couple of controls. The other issue is NPE but that shouldn't 
> be a problem because a reference to the Control instance is always 
> returned.
> 
> Thoughts?
> 
> bob
> 
> 

-- 
View this message in context: http://n2.nabble.com/Method-chaining-revisited-tp3156429p3159580.html
Sent from the click-development mailing list archive at Nabble.com.