TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Null is your friend, not a mistake

2 pointsby raytracerabout 6 years ago

1 comment

adrianmsmithabout 6 years ago
Ideally, as the article suggests, you should use a language which supports null and not-null types, with compile errors if you call a method on a type that might be null before checking to make sure it’s not null.<p>However, if you’re stuck with Java, which doesn’t do that, you can annotate your types with @Nonnull and @CheckForNull. (At least) SpotBugs and IntelliJ respect such annotations.<p>I have done this to every parameter type, return type, and instance variable on a 15 KLOC codebase and it’s been a great success.