Tag

Null Object pattern

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.

AssertionsJavaNull Object pattern
0 likes · 9 min read
Avoiding Excessive Null Checks in Java: Using Assertions, Exceptions, and the Null Object Pattern
Java Architect Essentials
Java Architect Essentials
Oct 8, 2021 · Fundamentals

How to Avoid Excessive Null Checks in Java: Best Practices and the Null Object Pattern

This article explains why excessive null‑checking in Java code is problematic, distinguishes when null is a valid response versus an error, and offers practical techniques such as using assertions, throwing exceptions, returning empty collections, and applying the Null Object pattern to write cleaner, safer code.

AssertionsJavaNull Object pattern
0 likes · 7 min read
How to Avoid Excessive Null Checks in Java: Best Practices 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.

JavaNull Object patternbackend development
0 likes · 6 min read
How to Eliminate Redundant Null Checks in Java with the Null Object Pattern
Selected Java Interview Questions
Selected Java Interview Questions
Apr 14, 2021 · Backend Development

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

This article explains why excessive null‑checking in Java code is problematic, distinguishes valid versus invalid null returns, and presents better alternatives such as assertions, throwing exceptions, returning empty collections or objects, and applying the Null Object pattern with concrete code examples.

AssertionsException HandlingJava
0 likes · 6 min read
Avoiding Null Checks in Java: When to Use Assertions, Exceptions, and the Null Object Pattern
Top Architect
Top Architect
Apr 12, 2021 · Backend Development

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

The article explains why excessive null‑checking in Java code is problematic, distinguishes between null as a valid response and as an error, and offers practical techniques such as assertions, throwing exceptions, returning empty collections, and applying the Null Object pattern to write cleaner, safer backend code.

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