I like using set instead of with for builders. I've only been using with
methods lately for constructing modified copies of the current object which
doesn't exactly fit the builder idea (since the builder is modified and not
copied). I've also used builders without any prefix, but that would look
rather silly mixed with setters and withers at this point.

On 14 November 2016 at 13:55, Gary Gregory <garydgreg...@gmail.com> wrote:

> I recently added a bunch of Builders in various places and used "with" as
> the setter method prefix.
>
> We have a mix of "set" and "with" in our Builders ATM.
>
> I am thinking of going back and changing the builders I added since 2.7
> from "with" to "set".
>
> I am liking "set" better because:
> - More standard than "with"
> - Therefore IDEs like Eclipse, by default will not generate warnings for
> setter methods when the param name is the same as the ivar (the param name
> is hidding a field)
> - Easier to remember to type "s" for "set" when using code completion
> - shorter than "set"
>
> I still like "with" ONLY in the case when a NEW object is generated, which
> is usually not (never?) the case in our Builders.
>
> Any thoughts?
>
> Gary
>
> --
> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> Java Persistence with Hibernate, Second Edition
> <https://www.amazon.com/gp/product/1617290459/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8>
>
> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1617290459>
> JUnit in Action, Second Edition
> <https://www.amazon.com/gp/product/1935182021/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22>
>
> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182021>
> Spring Batch in Action
> <https://www.amazon.com/gp/product/1935182951/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%7Blink_id%7D%7D%22%3ESpring+Batch+in+Action>
> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182951>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
Matt Sicker <boa...@gmail.com>

Reply via email to