Skip to main content
Software Engineering

Questions tagged [null]

Null is the absence of a value. Null is typically used to indicate that a reference or pointer variable points to no object in memory.

Filter by
Sorted by
Tagged with
8 votes
7 answers
5k views

Must getters return values as is?

We have entities with numeric properties, they are of boxed types (e.g. Integer). Typically, each of those properties has a pair of getters: getInt(), which returns zero on null values, and ...
3 votes
5 answers
1k views

What is the root cause of a proliferation of "null checks"?

I work with a lot of Groovy code. One feature of the language is the "safe navigation operator" (?), which I think of as an inline null check. There are many things about Groovy that I like, ...
2 votes
1 answer
230 views

checkNotNull vs. JEP 358: Helpful NullPointerExceptions: Should we remove existing null checks?

With the introduction of JEP 358 in Java 14, which provides more informative NullPointerException (NPE) messages, is it advisable to remove existing explicit null checks in cases where the null-check ...
ftb457932's user avatar
3 votes
4 answers
3k views

Are Optional fields okay?

Some fields may be optional. That is, a value doesn't have to be ever assigned to it. Luckily, Java has a special null-safer type for optional values — Optional However, if I try to make a field of ...
0 votes
2 answers
114 views

Modeling value object when fields' existence depends on state of other fields

I am practicing tactical DDD and having trouble as exemplified below. Fundamentally, whether some fields of the value object should be nullable depends on another field of the same value object. ...
-7 votes
1 answer
147 views

How to avoid NullPointerException(NPE) [closed]

Since we all know that few couple days ago there was a global outage (BSOD) because of the CrowdStrike updated which caused that global outage and the reason behind that was just an ...
5 votes
5 answers
1k views

Is it bad practice to use nullptr in ternary operation?

I've set up a ternary operator in place of a pile of if-else's, the final expression being nullptr in order to finish the loop, like so: int menuSelect; std::string operation=""; (...
0 votes
3 answers
176 views

Is there a distinct optional type semantically representing a value that *needs to be calculated later*?

Semantically, C++ std::optional, Rust Option<T>, and other optional/nullable types represent a value that can be present or absent: you have to handle both cases, or you can opt-in to crash. Is ...
JJW's user avatar
JJW
  • 9
1 vote
4 answers
3k views

Validating data classes with nullable properties that should never be null

When retreiving data with an api and saving it in a DTO, some values are nullable: null on initial class initialization but VS also warns you for this. For example, an employee: public class ...
16 votes
10 answers
5k views

Does 3-valued logic ever provide practical benefits over 2-valued logic?

I was looking at an SQL query recently and found what I think is likely a bug. It was related to case statements on inequalities. I was trying to replace it with a min/max type alternate and when ...
JimmyJames's user avatar
  • 30.8k
4 votes
3 answers
942 views

Is there a programming language other than Java, C#, and Go which includes null with its static object types?

I was reading the excellent book by Axel Raushmayer, Tackling TypeScript. In this section of Chapter 7, the author makes the interesting claim In many programming languages, null is part of all ...
20 votes
8 answers
9k views

Why assert for null on a object before asserting on some of its internals?

Let's consider the following test. [Fact] public void MyTest() { // Arrange Code var sut = new SystemWeTest(); // Act Code var response = sut.Request(); // Assert ...
2 votes
4 answers
697 views

Large Inheritance Hierarchy vs. One Object With Many Nullable Fields

I am working on implementing some stock order types for a financial technology application. There are six different types of stock orders - market, limit, stop_loss, stop_loss_limit, trailing_stop, ...
2 votes
3 answers
215 views

User's comment field on a row in relational databases

Suppose that we have a SQL relational database for, let's say, asset management system. It uses a table of assets (1 row per one real-world object). There can be various metadata etc. To allow the ...
47 votes
8 answers
29k views

What's wrong with returning null?

I've recenlty been greeted by CS8603 - Possible null reference return, which indicates that my code could possibly return null. It's a simple function that looks up an entity in a database by id - if ...
MechMK1's user avatar
  • 669

15 30 50 per page
1
2 3 4 5
...
9

AltStyle によって変換されたページ (->オリジナル) /