Skip to main content

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

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 ...
Sergey Zolotarev's user avatar
2 votes
1 answer
244 views

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
0 votes
2 answers
127 views

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. ...
STHA's user avatar
  • 71
5 votes
5 answers
1k views

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=""; (...
Hench's user avatar
  • 61
1 vote
4 answers
3k views

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 ...
Jannick Breunis's user avatar
4 votes
3 answers
1k views

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 ...
Ray Toal's user avatar
  • 1,325
2 votes
4 answers
741 views

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, ...
Treker's user avatar
  • 197
47 votes
8 answers
30k views

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
-1 votes
2 answers
5k views

Frequently in applications we encounter situations that could throw a NullReferenceException; for example, assuming the following method's argument is a user defined reference type, accessing the ...
Taco's user avatar
  • 1,175
0 votes
2 answers
766 views

Suppose I am buying coffee. There are several types of coffee (A1, A2, A3), but sometimes I want to make a reference to all types of coffee (like if I had a coffee "grouped"). Considering ...
André Luís Oliveira's user avatar
0 votes
1 answer
178 views

This come with a debate with my colleague that I'm using nullable object type. type Value = Node | null const [v0, setV0] = React.useState<Value>(null) const [v1, setV1] = React.useState&...
Mengo's user avatar
  • 669
2 votes
1 answer
322 views

Considering Kotlin Java Interop: Null Safety and Platform Types Why is code like this legal in Kotlin? fun envString(key: EnvVars): String { return System.getenv(key.toString()) } getenv() can ...
F.P's user avatar
  • 609
94 votes
11 answers
21k views

AFAIK, Option type will have runtime overhead, while nullable types won't, because Option time is an enum (consuming memory). Why not just mark optional references as optional, then the compiler can ...
Chayim Friedman's user avatar
3 votes
5 answers
12k views

I wanted to follow up on this previous question I asked related to @Laive comment, but I couldn't think of an excellent way to do so without asking another question, so here we go. With the previous ...
Ertai87's user avatar
  • 187
1 vote
1 answer
177 views

Let's say I have an which is loosely can be represented as: public class AnObject{ public AnObject(String name, String value, UUID id) { this.name = Objects.requireNonNull(...
Denis's user avatar
  • 113
0 votes
0 answers
199 views

I'm new to software engineering and right now I'm focused on learning the best practices to consistently write robust code. Recently I've been maintaining an application built by other people and/or ...
StackLloyd's user avatar
40 votes
8 answers
11k views

For example, suppose I have a class, Member, which has a lastChangePasswordTime: class Member{ . . . constructor(){ this.lastChangePasswordTime=null, } } whose lastChangePasswordTime ...
ocomfd's user avatar
  • 5,760
-2 votes
1 answer
939 views

Is it a good practice to use the static member methods to check if an object of a class is NULL or not. The object would be sent through the parameters offcourse. Something like, #include <...
Haris's user avatar
  • 105
-1 votes
2 answers
205 views

Using a website with Javascript as example. Let's say I have script A which only performs a specific function on page Foo. For example something like sorting elements in a list. Script A is only ...
kalenpw's user avatar
  • 109
1 vote
2 answers
2k views

Not using UncheckedIOException, NullPointerException possible public void callerMethod() { Object result = ioMethod(); // call instance method of result } public Object ioMethod() { ...
Mario Ishac's user avatar
3 votes
1 answer
342 views

I do not understand how you think about it:https://wiki.php.net/rfc/nullable_types when It is widely confirmed, that using nulls is bad practice Where am I wrong? thanks. I'm not criticizing !. I ...
BruceStackOverFlow's user avatar
38 votes
15 answers
11k views

This is one of the rules that are being repeated over and over and that perplex me. Nulls are evil and should be avoided whenever possible. But, but - from my naivety, let me scream - sometimes a ...
gaazkam's user avatar
  • 4,529
3 votes
3 answers
3k views

I have a RESTFUL api, one of the endpoints is receiving search criteria which contains property for "Title". Should I allow consumers to send either null (or eliminate the property) or Empty string in ...
Dabbas's user avatar
  • 260
-1 votes
1 answer
351 views

Do Special Case or Null Object design patterns still provide value when application behavior, not just object behavior has to change? I was tasked with revisiting an old application and refactoring ...
PieMaker's user avatar
2 votes
3 answers
265 views

When I program in Java, I make all nullability explicit; that is, an instance of Foo is assumed to be non-null, and if I want it to be null, I use a @Nullable annotation (or better, Optional<Foo>...
Nick Tobey's user avatar