Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

Handling of nulls in CSX

Tolik Pylypchuk edited this page Feb 21, 2018 · 1 revision

Almost everything in CSX doesn't tolerate null at all. And in my opinion that's how it should be, because usually null values cause more problems than they solve. But this is not a philosophical blog entry about whether or not to use null values.

Every method of every class in CSX will throw an ArgumentNullException if it encounters null values. There are some exceptions to this rule. If a method allows a null value as its parameter, it is always explicitly specified in the documentation.

The most prominent example is the From method in the Option class. The whole point of Option is to explicitly specify that a value may or may not be there. From returns a non-empty option for any value which is not null, or an empty option otherwise. If an option contains a value, it is guaranteed that this value is not null.

I've created an exception type UnacceptableNullException which should be thrown for general cases when null values are not welcome.

Clone this wiki locally