That would definitely be a nicer way to do it. Although, using the builder pattern to create parameters for every single method in your API would be a gigantic pain.
Javascript APIs hack this in by taking Objects as params so that you can do {name='Alfred E. Neuman'...}. Unfortunately, Java's syntax isn't nice for creating Maps either, but maybe you could do something with that.
In the end, this seems like a problem with the language syntax and any fix other than one at the language level is going to be a hack.
I think this way is better:
o.doSomething({
name : "Alfred E. Neumann",
link : "http://blog.schauderhaft.de,
ultimateAnswer: 42,
tempFile: "c:\\temp\\x.txt",
zip : 23});another example of Builder pattern http://goo.gl/NkAhE
Re:Named Parameters in Java
by moondowner on Friday August 10, 2012 @10:34AM
(#4366319)
or ObjectName.getBuilder("Alfred E. Neumann", "http://blog.schauderhaft.de, 42, "c:\\temp\\x.txt", 23).build(); maybe?
It's not addressing named parameters issue, but I find it better like this.
object.setName("Alfred E. Neumann") .setLink("http://blog.schauderhaft.de) .setUltimateAnswer(42) .setTempFile("c:\\temp\\x.txt") .setZip(23);