java - Check parameters annotated with @Nonnull for null? - Programmers Stack Exchange
Well, consider why you don't write
this.name = Preconditions.checkNotNull(name); // Might be necessary that.name = Preconditions.checkNotNull(this.name); // Who knows?
Programming isn't black magic. Variables don't suddenly become Null. If you know a variable isn't Null, and you know it's not changed, then do not check it.
If you do check it, some programmer in the future (possibly you) will spend a lot of time finding out why that check is there. The check must be there for a reason, after all, so what are you overlooking?
Read full article from java - Check parameters annotated with @Nonnull for null? - Programmers Stack Exchange
No comments:
Post a Comment