Relative Content

Tag Archive for null

Check parameters annotated with @Nonnull for null?

We’ve begun using FindBugs and annotating our parameters with @Nonnull appropriately, and it works great to point out bugs early in the cycle. So far we have continued checking these arguments for null using Guava’s checkNotNull, but I would prefer to check for null only at the edges–places where the value can come in without having been checked for null, e.g., a SOAP request.

AND is better or using Internal “IF” [duplicate]

This question already has answers here: Is it bad practice to use short-circuit evaluation instead of an if clause? [duplicate] (7 answers) Closed 9 years ago. In a situation like this:” if ((metadata != null) && (metadata.TypeEnum != VariantInfoMetadata.CellTypeEnum.Status)) do you recommend to keep the code as it is above? Or is it better to […]

null values vs “empty” singleton for optional fields

First of all I’m developing a parser for an XML-based format for 3D graphics called XGL.
But this question can be applied to any situation when you have fields in your class that are optional i.e. the value of this field can be missing.

Requiring Explicit Null Reference Handling

One of the problems I have with null references is that they may not be exceptional. In my current position, there are few requirements and you are lucky if conventions are followed. This means being unable to handle a request is a frequent occurrence and throwing an exception is too slow (think millions of requests). I am in charge of writing an api for handling these requests and I am trying to decide how to handle failures.