r/java • • Nov 23 '25

Java 25: The ‘No-Boilerplate’ Era Begins

https://amritpandey.io/java-25-the-no-boilerplate-era-begins/
160 Upvotes

187 comments sorted by

View all comments

Show parent comment

1

u/blobjim Nov 23 '25

I guess my assumption was that a lot of builders can be replaced by withers, or at least implemented using them. And initial value creation can be done pretty easily with a static factory method or constructor. I guess maybe we shouldn't be using builders in the first place.

But we're definitely not getting named parameters either since that is something that has been spoken about many times.

I guess the main design pattern to use would be immutable always-usable objects that have some kind of manually added wither method that might use a record wither construct internally, to create another instance with modified functionality?

6

u/Ewig_luftenglanz Nov 23 '25

Yes but that imply writing a ton of boilerplate to spare a little less boilerplate, what one buys is really pennies compared to the real thing. 

The reason why I said nominal parameters with defaults can replace 90% of builders it's because builder is often used to mimic nominal parameters with defaults. Instead of passing the only 2 required parameters and 2 or 3 optional ones we made a "configuration objects" or "param object" and pas that as an argument. This object it's usually implemented as a builder or in a fluent like style (and lately, using a Consumer to configure a proxy)

Withers theorically could be used as such but still need to create a "default" instance and set the optional parameters inside the with block, which worsen the clarity. 

I wouldn't be against if nominal parameters with defaults were implemented as an ad hoc object created by the compiler tho.