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 > > <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 > <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 > <mailto: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 > <mailto: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 <mailto:boa...@gmail.com>> > > > > -- > E-Mail: garydgreg...@gmail.com <mailto:garydgreg...@gmail.com> | > ggreg...@apache.org <mailto: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 <http://garygregory.wordpress.com/> > Home: http://garygregory.com/ <http://garygregory.com/> > Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>