Honestly, we have a ton of like 15 parameter records and all arg constructors. I wouldn't say it's that bad, at least we get compiler errors everywhere when we add a new field to the record (most common update to a record by far).
Mutating state with a with doesn't get called out when you add a new field, which is convenient, but can hide bugs if you imagine that any with/copy constructor is actually an operation that someone should verify isn't broken with a new field addition.
Not entirely sure, but I think this can be alleviated a bit, once we get withers. Then one can then simply define a "template" instance and instantiate modified copies of that. Something like this (forgive the syntax, I have no Idea, how withers are going to eventually look like):
record Point3D(int x, int y, int z) {
public final static Point3D DEFAULT = new Point3D(0, 0, 0);
}
and used like this:
var thePoint = Point3D.DEFAULT with { x = 10, y = 45 };
View all comments
Show parent comment
15
u/Puzzleheaded-Eye6596 Jan 22 '26
records can get horrible to instantiate. named arguments would be so helpful