|
|
|
|
|
by gav
4807 days ago
|
|
I've worked on a lot of legacy Java code where these kind of null checks cause problems. The end up confusing things in corner cases. You should verify arguments at a top level, then let the code underneath blow up with a NullPointerException if something unexpected happened. Your stack trace will point at where the problem lies. I find for some reason that a lot of people want to use null instead of empty lists where you'll end up with this ugliness: if (list != null) {
for (Thing t: list) {
processThing(t);
}
}
Instead of just passing in a Collections.emptyList() instead. |
|