Tagged articles
3 articles
Page 1 of 1
Java Captain
Java Captain
Dec 25, 2019 · Backend Development

Handling Null Values and Optional in Java: Best Practices and Design Patterns

This article discusses common null‑value pitfalls in Java services, explains why returning null collections is dangerous, and presents robust solutions such as returning empty lists, using Optional, applying JSR‑303/JSR‑305 annotations, and employing the Null Object pattern to improve code safety and readability.

Design PatternsJSR-303JSR-305
0 likes · 13 min read
Handling Null Values and Optional in Java: Best Practices and Design Patterns
Java Backend Technology
Java Backend Technology
Dec 18, 2019 · Backend Development

Mastering Null Handling in Java: Optional, Null Object Pattern & JSR 303/305

This article examines common pitfalls of null values in Java backend code, explains why returning null collections or objects can cause NullPointerExceptions, and presents robust solutions such as returning empty collections, using Optional, applying JSR‑303 validation, JSR‑305 annotations, and the Null Object pattern to improve API safety and readability.

JSR-303JSR-305Java
0 likes · 13 min read
Mastering Null Handling in Java: Optional, Null Object Pattern & JSR 303/305