4 ms·
> mainly because "fluent" chains should never be mutating their operand. I see this quite often with builders, actually, and I don't mind it so much there.
by vitus 2y ago
> mainly because "fluent" chains should never be mutating their operand.
I see this quite often with builders, actually, and I don't mind it so much there.
FooBuilder()
.setBar(bar)
.setBaz(baz)
.setQux(qux)
.build()
- wegfawefgawefg 2y agoeverytime i see this i just would prefer a variadic function lol
- vitus 2y agoIf your language supports named arguments, sure, but that's not always a given.
- wegfawefgawefg 2y agoi dont buy it. this pattern was common in rust and then fell out of favor. in c or go if you dont like variadics just pass in a params struct. its just a fad.
- vitus 2y ago> in c or go if you dont like variadics just pass in a params struct. Which, again, is fine if your language supports named args for your params struct. C++ didn't have this until C++20, despite C having it for decades prior. Java still doesn't have this. If your language doesn't have named args or designated initializers or whatever it calls them, then what, perform your function calls with argument comments of the form f(/*foo=*/1, /*bar=*/2, /*baz=*/true)? That's error-prone even in the best-case scenario.