Tagged articles
5 articles
Page 1 of 1
Top Architect
Top Architect
Oct 10, 2024 · Backend Development

Avoiding Excessive Null Checks in Java: Using Assertions, Exceptions, and the Null Object Pattern

This article explains why overusing null‑check statements in Java leads to verbose code, distinguishes cases where null is a valid response versus an error, and offers practical techniques such as assertions, throwing exceptions, returning empty collections, and applying the Null Object pattern to write cleaner backend code.

Backend DevelopmentExceptionsJava
0 likes · 9 min read
Avoiding Excessive Null Checks in Java: Using Assertions, Exceptions, and the Null Object Pattern
Top Architect
Top Architect
Jul 4, 2021 · Fundamentals

Avoiding Null Checks in Java: Assertions, Exceptions, and the Null Object Pattern

This article explains how to distinguish between valid and invalid null returns in Java, recommends using assertions or exceptions for erroneous nulls, suggests returning empty collections or objects, and demonstrates the Null Object pattern with code examples to eliminate repetitive null‑pointer checks.

Exception HandlingJavaNull Object pattern
0 likes · 6 min read
Avoiding Null Checks in Java: Assertions, Exceptions, and the Null Object Pattern
macrozheng
macrozheng
Apr 22, 2021 · Backend Development

How to Eliminate Redundant Null Checks in Java with the Null Object Pattern

This article explains why excessive null‑checking code appears in Java projects, distinguishes valid versus error null values, and offers practical techniques—including asserts, exceptions, empty collections, and the Null Object pattern—to write cleaner, safer backend code.

JavaNull Object patternbest practices
0 likes · 6 min read
How to Eliminate Redundant Null Checks in Java with the Null Object Pattern