Null Safety approach with forced "!"
Am I the only one who thinks that introducing protection against NPEx in the form of using "!" in the variable type is a very, very bad idea? In my experience, 95% of variables should be non-null. If Oracle decides to take this approach, we will have millions of "!" in each variable in the code, which is tragic for readability. In C#, you can set the per project flag to indicate whether the type without the "?" /"!" is nullable or not. I understand the drawbacks, but definitely forcing a "!" in 95% of variables is tragic.
78
Upvotes
View all comments
Show parent comment
5
u/kevinb9n Feb 26 '26 edited Feb 26 '26
Or module.
If you don't use modules, package is as wide as you can go (and it does not include "subpackages" which aren't really a thing in Java). But be a little bit careful; packages outside of modules are slippery concepts. You can end up in a situation where the same class is sometimes seen with a `package-info` present and sometimes not, changing the meaning of the unannotated type usages throughout.