Java 16+ records are so nice! Let's say you have this code:
5
6
1
53
What about replacing it with:
3
2
26
Functions/constructors/whatever which take a number of booleans greater than one upset me. Does this record make sense if something is false, X, true, X ? If not, then perhaps a enumeration of not/can/is generating would be better?
1
yes in this case it does. It's used as a key for my baked model which has a few booleans that determine it's shape. So this is the best solution here IMHO. Otherwise you just get an explosion of binary combinations and that's ugly
1
oh well. That is painful for you, but I guess if the scope is limited then you've got the best you can have.
1
Why is it painful? I don't really see a problem with that to be honest. Class/records with several booleans in it are VERY common
1
Replying to @McJty
the record is fine. Its the function arguments which I find uncomfortable. Sequences of true/false withno surrounding semantics hurt my brain.

Dec 29, 2021 ยท 10:25 AM UTC

2
Replying to @dsilverstone
Ah yes, I agree with that. But the thing we were talking about was a record
1
the shorthand record definition is nice. Does it imply a nasty constructor though, or do you get typestate builders for free? Eg. ModelData.new().generating().actuallyGenerating()
1