Thinking about special values
Thursday, April 17th, 2008Is it good to have something like that:

To me -1 or -99999 is not a good way to express absence of item. Why? Because this is syntactical level which is rather concrete - which means it could change in unexpected way.
In case the function/method would return special values it will be better to have someting like this:

then:
if ( table.IndexOf(column) == -1)
{
return ColumnIndex.NullIndex;
}
Looks better, but again not perfect. This approach now using semantical differences between ordinary index and NullIndex.
Another step - distinguish special empty class:

But this is also not perfect…..