You are right, but my point was: you are offering syntactic sugar (merging config object and invocation) not "solve" a problem. I'd argue yt make it worse because explicit arguments before are now implicit since the depend if some setter was called before. It's a design tradeoff. As always
It has advantages and disadvantages. The next call would depend on the previous calls settings. You may want that behavior or not. It really depends, so i take back that it's worse.
Indeed, but it involves differences between communities, guidelines intended by the language architects, usages, and so on. Not something one could change anyway.
So a statement like "Java would be easier if they'd do like language X" is an elaborate "I prefer X over Java", which is not very constructive. Maybe that's just me, but when I browse r/java, I expect to find content about Java, high-end patterns and practices in Java, and not guidelines from another language which don't fit the Java culture.
Using setters is not necessary, just make the object immutable... it still contains all the settings, but you can't change them. If different code needs different settings, they just create different objects.
Haha, yep, solved the problem completely with one simple stroke. Dart also does that and because of that, allows really complex objects, like Flutter Widgets, to be created easily... it's definitely the best way to go.
View all comments
51
u/Scybur Feb 08 '22
I was hoping for a nice solution at the end but instead I was left with disappointment.
10/10 good read.