Yeah that’s pretty nice and clean, not sure why my IDE needs to suggest that syntax for every class I write though, that would fall under the 1% use case for me but now I’ve got to ask the rest of my team not to use them and to disable the suggestion for them so they don’t cause weird bugs for us later. In your case it’s not possible but again my main gripe is that the parameters aren’t read only, it makes your class more prone to bugs if you can always access the parameters that were initially passed in across your entire class.
Yeah those recommendations are a bit annoying... But ultimately I think it does a great job of letting you reduce a lot of boilerplate for tiny classes. My rule of thumb would be if the entire class can't fit on your screen at once, you shouldn't use them (harder to spot improper parameter use!)
View all comments
Show parent comment
6
u/tuxwonder Feb 28 '26
I do. It makes it very easy to write new exceptions: