I think it depends on formatting, I find something like:

Builder.create().
   foo("Hello").
   bar("World").
   baz("!").
end();

to be just as readable, if not more so than

Builder b = Builder.create();
b.setFoo("Hello");
b.setBar("World")
b.setBar("!");

Not just because it's less typing and repetition, but because the
repeated boilerplate and non-indentation obscure the hierarchy. This
is one area where I like Python, Haskell, YML, etc is that structuring
the code visually aids in rapid understanding of relationships.

-Ray


On Thu, Apr 16, 2009 at 12:48 PM, Isaac Truett <[email protected]> wrote:
>
> Personally I don't care for this style of coding. I think it's very
> convenient for writing, but it hurts readability.
>
>
> On Thu, Apr 16, 2009 at 2:03 PM, Eric Ayers <[email protected]> wrote:
>> Recently I've been wrapping some of my JavaScriptObjects using the builder
>> pattern where an instance of the object you are setting is in the return
>> value.
>>
>>   http://galgwt-reviews.appspot.com/21604/diff/1/18?context=10
>>
>> Which you would invoke as:
>>
>>
>>   DraggableObject obj = new DraggableObject(elem,
>> DraggableObjectOptions.newInstance().setLeft(10).setTop(5));
>>
>> Can anyone think of a reason I might be shooting myself in the foot
>> performance wise or code size wise as opposed to making these strict setter
>> methods?  I don't want to set a bad example.
>>
>> -Eric.
>> --
>> Eric Z. Ayers - GWT Team - Atlanta, GA USA
>> http://code.google.com/webtoolkit/
>>
>> >
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to