



General rule is this: if your model has a value which is not compulsory, without which it can be created, it can be Optional, otherwise try to avoid Optionals as much as you can, to save yourself from a load of null checks.įor example, if you have a Registration screen in your application, and a user can but doesn’t have to provide an image, the image can be Optional. Also, I’ll be referring to the Nullable type here as Optional, to better fit people with knowledge from other languages (such as Swift), but in reality, it has nothing to do with Java’s Optional. I’d rather give you guidelines on how, why, and where to use an Optional value. I won’t go as much into detail with the syntax because there’s some great documentation on it.
