Tag

Null Object

0 views collected around this technical thread.

Top Architect
Top Architect
Jun 20, 2024 · Backend Development

When and How to Use Null Checks in Java: Best Practices and Alternatives

This article discusses the proper use of null‑checking in Java, distinguishes between valid and invalid null returns, proposes alternatives such as returning empty collections, using assertions or throwing exceptions, and demonstrates the Null Object pattern with concrete code examples while also noting related community resources.

Backend DevelopmentDesign PatternsJava
0 likes · 9 min read
When and How to Use Null Checks in Java: Best Practices and Alternatives
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.

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