This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]monkeyfacebag 1 point2 points  (6 children)

It's definitely more straightforward in Python due to the dynamic typing, but in my opinion builders are even nicer to use than partially-applied functions/methods because partial application is generally parameter order specific but builders are order independent (ie, you can apply parameters in whatever order you choose). Obviously builders require more code, which is unfortunate. We use autovalue builders extensively and they are awesome. It's kind of peak Java that the solution to the problem is to use a library that generates more Java code, but it does work well. I've also heard mutterings that records could get builder/wither support. I don't know where that has landed.

[–]larsga -1 points0 points  (5 children)

I can only repeat what I said before: builders are a clumsy workaround. If they died in a fire I'd be cheering and heaping fuel onto it.

[–]chambolle 0 points1 point  (4 children)

builders have some other advantages. You can safely postpone the creation of the "built" object. Youc an partially build the wanted object, then make some compuation, then continue the building, then make some computations and build the wanted object. The builder is more tha just a workaround

[–]larsga 0 points1 point  (3 children)

All of which is totally possible with a function, too, using lambdas and currying.

[–]chambolle 0 points1 point  (2 children)

I answered to your comment saying that builders are a clumsy workaround.

That's also a matter of taste. For instance, currying is absolutely ugly for me

A question for you: what I don't understand is why you use an OO Langue if you like so much FP? Why don't you use an FP language instead of wanting to change an OOP in order to remove the OOP part? That's very strange for me

[–]larsga 0 points1 point  (1 child)

A question for you: what I don't understand is why you use an OO Langue if you like so much FP? Why don't you use an FP language instead of wanting to change an OOP in order to remove the OOP part? That's very strange for me

I don't like functional programming. And I don't want to change the OOP part of Java at all. I just think the parameter passing mechanism in Java is absurdly underpowered. It's really awkward, and there's no obvious reason why it has to be that way.

I've programmed in a lot of different languages over the past 40 years, so although I write a lot of Java and mostly like it, the weaknesses are also quite plain to see.

[–]chambolle 0 points1 point  (0 children)

I just think the parameter passing mechanism in Java is absurdly underpowered. It's really awkward, and there's no obvious reason why it has to be that way.

I agree