0

Should I implement named parameters in Java using Hash tables?

I saw this entry:

Named Parameter idiom in Java

: but I did not want to use the builder method which seemed overly verbose

Community
  • 1
  • 1
yazz.com
  • 57,320
  • 66
  • 234
  • 385
  • 1
    a map of type Map can be used for this – Stefan De Boey Mar 04 '10 at 12:38
  • What are you trying to accomplish? – dj_segfault Mar 04 '10 at 12:45
  • I want named parameters that look very readable. Have you ever seen Ruby's named parameters as a good example? I guess I didn't want to mention Ruby in the question though as I want to see what different techniques there are, and not get into a language debate :) – yazz.com Mar 04 '10 at 12:47

1 Answers1

3

There is no such thing as named parameters in Java.

There are workarounds and there have been submissions in Project Coin but they were rejected. Sun is well aware that there is a demand but, so far, they have rejected any such language change.

Using Maps as suggested above is a possibility but unless all your arguments have the same type, it is cumbersome. And it's not really efficient either.

Xr.
  • 1,410
  • 13
  • 23