Avoiding NullPointerException - DZone Java : vimarsana.com
Avoiding NullPointerException - DZone Java
Avoiding NullPointerException
In this article, we ll explore the main techniques to fight it: the self-validating model and the Optional wrapper.
by
The terrible
NullPointerException (NPE in short) is the most frequent Java exception occurring in production, according to a 2016 study. In this article, we ll explore the main techniques to fight it: the self-validating model and the
Optional wrapper.
Self-Validating Model
Imagine a business rule: every Customer has to have a birth date set. There are a number of ways to implement this constraint: validating the user data on the create and update use-cases, enforcing it via
NOT NULL database constraint and/or implementing the null-check right in the constructor of the Customer entity. In this article, we ll explore the last one.
Related Keywords
, Member Card, Clean Architecture, Data Transfer Objects, Domain Model, உறுப்பினர் அட்டை, சுத்தமான கட்டிடக்கலை, தகவல்கள் பரிமாற்றம் பொருள்கள், களம் மாதிரி,