Tag

null checks

0 views collected around this technical thread.

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.

AssertionsBackend DevelopmentJava
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.

AssertionsException HandlingJava
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.

Backend DevelopmentJavaNull Object pattern
0 likes · 6 min read
How to Eliminate Redundant Null Checks in Java with the Null Object Pattern
Top Architect
Top Architect
Jun 11, 2020 · Fundamentals

When to Use Null Checks, Assertions, Exceptions, and the Null Object Pattern in Java

The article explains why excessive null‑checking clutters code, distinguishes when null is a valid response versus an error, and recommends using assertions, exceptions, empty collections, or the Null Object pattern to write cleaner, safer Java programs.

AssertionsException HandlingJava
0 likes · 6 min read
When to Use Null Checks, Assertions, Exceptions, and the Null Object Pattern in Java