Why can values be null in .NET? Is this superior to having a guarantee where everything would have a value and nothing call be null?
Anyone knows what each of these
Ok now wrap to the magic word of C#-without-null
class View
{
Model model;
public View(Model model)
{
Console.WriteLine("my model : {0}, thing : {1}", this.model, this.model.thing);
this.model = model;
}
}
What is printed on the console?
So basically for me it don't seem to solve anything to remove a null state, as the possibly invalid state still need to be managed anyway...
Oh buy the way what would be the default value of an interface ? Oh and an abstract class what would happen when a method is called on a default value that is defined in the abstract class but that call another method that is abstract ? .... .... Why oh why complicating the model for nothing, it's multiple-inheritance questions all over again !
One solution would be to change the syntax completely to go for a full functional one where the null world doesn't exits, only Maybes when you want them to exists... But it's not a C like language and the multi-paradigm-ness of .Net would be lost.
What might be missing is a null-propagating operator able to return null to model.Thing when model is null, like model.?.Thing
Oh and for good mesure an answer to your question :
Nothing as it is called in VB would have radically changed the language, it already took years for users to switch from VB6 to VB.Net such a paradigm change might have been fatal for the language.