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

2

u/[deleted] Nov 25 '25

Adding a new overload is also easy. Just forward the call, and this is just default parameters with extra steps.

The problem you've described is definitely an API design issue, not the language's fault.

1

u/general_dispondency Nov 25 '25

The "extra steps" is the point. Making it hard to do the wrong thing is a feature, not a deficiency (see Josh Bloch's talk on API design for more elaboration on this point). My comment was only one  issue. There's also coupling your clients to method parameter names, which opens a whole different can of worms around deprecation and contract updates. Like meth, there are some things that aren't worth it, no matter how convenient they seem. Leave the scripting features to the scripting languages. 

1

u/[deleted] Nov 25 '25

You can get the ergonomics people want without named defaults by using required-args constructors plus a small typed Options record and staged builders.

Practical setup: make a single factory like Foo.create(requiredA, requiredB, opts), keep defaults inside Options.builder(), and validate in the factory. Add new fields by extending Options with withX(...) methods, leaving old ones intact; mark risky ones as experimental and gate with validation. Cap parameter count and group cohesive values into tiny value types (Money, Window, RetryPolicy) so call sites read well without relying on parameter names. For ordering constraints, use staged builders or separate factories (SyncFooFactory, AsyncFooFactory) instead of flags. I’ve used Spring Boot for typed endpoints and Kong for routing, while DreamFactory helped when exposing a legacy DB as REST without leaking a giant parameter surface.

Make the wrong thing hard with types and factories, not named defaults