Hello Edgar,

I have had the same issue some days ago with one of my coworker about the
method chaining. I do not see any problem with the method chaining. Some
people might argue that the code starts to loose its readability after
certain level of chaining. Also, the chaining will not work for cases where
we have return values. Otherwise I don't see any problem with that, in fact,
I like to chain method calls up to a certain level.

Regards,

Jahid



On Mon, May 17, 2010 at 2:51 PM, Malcolm Edgar <[email protected]>wrote:

> Hi All,
>
> I have been playing around with some new concepts for Click and been
> writing code using method chaining. Its something I have argued
> against for a long time, as its something I would never recommend
> developers do in their application code because you can get the train
> wreak anti-pattern.  However its an idea I have finally come around
> to. I think it would be really handy if the Click control setter
> method returned their instance, so that you could write code like the
> following:
>
> TextField passwordField = new
>
> PasswordField("password").setMaxLength(20).setMinLength(5).setRequired(true);
>
> Column column = new
> Column("age").setFormat(""{0,number,#,###}").setTextAlign("right");
>
> This would alleviate the requirement for using builder/factory
> patterns in many instance, which are very useful in their own right.
>
> Any thoughts?  Frederic Daoud :)
>
> regards Malcolm Edgar
>

Reply via email to