4 ms·
My personal ask for the language designers is somewhat similar, but not quite this (it seems). I'd like to have either the language support for builders or sett
by diebir 8y ago
My personal ask for the language designers is somewhat similar, but not quite this (it seems). I'd like to have either the language support for builders or setters where after creation an object becomes immutable.
The options we have right now are bad: the long constructor arguments are too verbose, the setters are causing non-immutability and builders are worst due to lack of discoverability and standards.
- jdmichal 8y agoThat sounds like a need for named and default constructor parameters. With the two of those, you can mix-and-match whatever values you want, with non-defaulted ones being required. And since the parameters are named, they self-document at the usage site.
- kjeetgill 8y agoI know it's not quite what you're asking for but Java's annotations allow for pretty reasonable and compose-able preprocessors to implement things like this. Checkout lombok's @Builder annotation https://projectlombok.org/features/Builder https://projectlombok.org/features/Builder