4 ms·
Depends really. Can getAddress() return null or is it guaranteed to be there per your system design? If it's not then that code is wrong, but if you know your i
by EpicEng 8y ago
Depends really. Can getAddress() return null or is it guaranteed to be there per your system design? If it's not then that code is wrong, but if you know your invariants and enforce them higher up the chain then perhaps not.
I realize that all sounds very obvious, but like most things... it really does depend. It can certainly make debugging harder if you need to step through. Personally I try to write code which simply doesn't allow nulls below the first layer they may be encountered. Not always possible though (e.g. nullable fields in entities and whatnot.)
- nradov 8y agoThis is where annotation based null analysis can really help. https://dzone.com/articles/eclipse-annotation-based-null-analysis https://dzone.com/articles/eclipse-annotation-based-null-ana...