Tag

default values

0 views collected around this technical thread.

Code Mala Tang
Code Mala Tang
Jun 11, 2025 · Fundamentals

Master Python’s @dataclass: Simplify Class Creation and Management

Learn how Python’s @dataclass decorator, introduced in Python 3.7, streamlines class definition by automatically generating constructors, string representations, and more, while covering default values, mutable defaults handling, field exclusion, read‑only classes, and conversion to tuples and dictionaries for efficient data handling.

Pythonasdictclass definition
0 likes · 8 min read
Master Python’s @dataclass: Simplify Class Creation and Management
Code Mala Tang
Code Mala Tang
Mar 29, 2025 · Fundamentals

Better Ways to Handle Missing Values in Python Instead of Returning None

This article explains why returning None for missing values can cause unexpected errors in Python code and presents five practical alternatives—including default values, raising exceptions, special objects, type‑hinted optional returns, and dataclasses—to handle absent data safely and cleanly.

Error HandlingPythondataclasses
0 likes · 4 min read
Better Ways to Handle Missing Values in Python Instead of Returning None
Code Mala Tang
Code Mala Tang
Mar 27, 2025 · Fundamentals

Why Returning None Is Bad and Better Ways to Handle Missing Values in Python

Returning None for missing data can cause unexpected crashes, so this article explains why that approach is problematic and demonstrates safer alternatives in Python, such as using default values with dict.get, raising exceptions when appropriate, and employing result objects to clearly indicate success or failure.

Error HandlingNone handlingPython
0 likes · 3 min read
Why Returning None Is Bad and Better Ways to Handle Missing Values in Python
Sanyou's Java Diary
Sanyou's Java Diary
Mar 28, 2024 · Backend Development

Why Lombok’s @Builder Drops Default Values and How to Fix It

This article walks through a real‑world NPE caused by Lombok’s @Builder ignoring field initializers, explains the underlying double‑initialisation bug, shows how @Builder.Default restores the defaults, and outlines Lombok’s compile‑time annotation processing mechanism.

Builder PatternCompile-time AnnotationJava
0 likes · 15 min read
Why Lombok’s @Builder Drops Default Values and How to Fix It