Quick followup as I chug through the archives: I've been using setFoo() since it's easier to generate. Just create setters, then copy/paste the return type from void to Builder and add a "return this;" line to each method. It's rather manual, but the IDE plugins I've tried using to do this in the past are all really buggy.
On 30 November 2015 at 16:25, Ralph Goers <ralph.go...@dslextreme.com> wrote: > Oh, right. I forgot the setter was on the builder, not the actual object. > Forget I said anything. > > Ralph > > On Nov 30, 2015, at 3:11 PM, Matt Sicker <boa...@gmail.com> wrote: > > Builders are for creating immutable objects. > > On 30 November 2015 at 15:30, Ralph Goers <ralph.go...@dslextreme.com> > wrote: > >> Generally I prefer factories over builders because the objects created >> are immutable. OTOH, the new Builder for the Configuration creates an >> intermediate object. The actual objects use the “normal” plugin >> builders/factories so they can still be immutable. >> >> Ralph >> >> On Nov 30, 2015, at 12:49 PM, Paul Benedict <pbened...@apache.org> wrote: >> >> I actually had an interesting discussion lately with builders; so this >> topic interests me. Since builders are inherently mutable (and they should >> be right? it's a process of constructing an object), it's okay to use "set" >> methods. For example, see Spring's BeanDefinitionBuilder [1]. But you don't >> have to take this approach. It's also fine to name the mutator like an >> operation; see Java EE's URIBuilder [2] for that approach. >> >> My preference comes down to whether the in-process information is >> retrievable? If so, I prefer getter/setter; otherwise just go with foo() >> over setFoo() >> >> [1] >> https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/beans/factory/support/BeanDefinitionBuilder.html >> [2] https://docs.oracle.com/javaee/7/api/javax/ws/rs/core/UriBuilder.html >> >> Cheers, >> Paul >> >> On Mon, Nov 30, 2015 at 1:44 PM, Gary Gregory <garydgreg...@gmail.com> >> wrote: >> >>> I like "set" better, but that's just because I like to type "set" and >>> use auto-complete. I'd rather not have to decide if I have to type "set" or >>> "with" and then auto-complete. >>> >>> Gary >>> >>> On Mon, Nov 30, 2015 at 11:36 AM, Matt Sicker <boa...@gmail.com> wrote: >>> >>>> Sorry, but I introduced this problem a while ago by using withFoo() in >>>> some builder classes, but setFoo() in other builder classes. Both are >>>> equally valid naming schemes for builder classes. It would be great to be >>>> consistent, though. Which one would be preferable? >>>> >>>> -- >>>> Matt Sicker <boa...@gmail.com> >>>> >>> >>> >>> >>> -- >>> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org >>> Java Persistence with Hibernate, Second Edition >>> <http://www.manning.com/bauer3/> >>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> >>> Spring Batch in Action <http://www.manning.com/templier/> >>> Blog: http://garygregory.wordpress.com >>> Home: http://garygregory.com/ >>> Tweet! http://twitter.com/GaryGregory >>> >> >> >> > > > -- > Matt Sicker <boa...@gmail.com> > > > -- Matt Sicker <boa...@gmail.com>