I make everything final and annotate every return type and parameter as either @NotNull or @Nullable. Some people say it's too verbose, but it has cut down the amount of mistakes I make by probably an order of magnitude.
Or I just use Kotlin and get all of this and more for free. :)
That's not a bad idea. I find myself using @NotNull WAY more often than @Nullable so maybe only annotating the latter is a good way to cut down on verbosity while also getting the same linter warnings.
Though I think it still might be worth annotating parameters as @NotNull because I believe you can still pass @Nullable values to non-annotated params without triggering the lint warning, right?
5
u/Paradiesstaub Nov 26 '16
How about making everything possible
final(class, method, variables).