Named Parameters in Java another Alternative

I wrote before about how you can emulate named parameters in a Java, either using methods or a builder. There is another approach, which already got mentioned in the comments. On the usage side it looks like this:     doSomething4(new ParameterObject() {{         name = "Alfred E. Neumann";       [...]

Posted in: Softwaredevelopment by Jens Schauder 1 Comment ,

Named Parameters in Java – an Alternative

In the last installment of this blog I wrote about a way to fake Named Parameters in Java. As so often there are many ways to do this, so here comes another one. Instead of static methods producing value objects for each parameter you can use a single parameter object that happens to be a [...]

Posted in: Softwaredevelopment by Jens Schauder 11 Comments , ,

Named Parameters in Java

I lately came across some code that looked like this: o.doSomething1(     "Alfred E. Neumann",     "http://blog.schauderhaft.de",     42,     "c:\\temp\\x.txt",     23); Things were actually worse since there where about 20 or 30 such calls and there was no hint what so ever to the difference in meaning of [...]

Posted in: Softwaredevelopment by Jens Schauder 9 Comments , ,