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 <[email protected]> wrote:
> 
> Builders are for creating immutable objects.
> 
> On 30 November 2015 at 15:30, Ralph Goers <[email protected] 
> <mailto:[email protected]>> 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 <[email protected] 
>> <mailto:[email protected]>> 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 <[email protected] 
>> <mailto:[email protected]>> 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 <[email protected] 
>> <mailto:[email protected]>> 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 <[email protected] <mailto:[email protected]>>
>> 
>> 
>> 
>> -- 
>> E-Mail: [email protected] <mailto:[email protected]> | 
>> [email protected]  <mailto:[email protected]>
>> 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>
> 
> 
> 
> 
> -- 
> Matt Sicker <[email protected] <mailto:[email protected]>>

Reply via email to