Non-null objects, the Null Object pattern, and T.init

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Jan 17 16:15:22 PST 2014


On 1/17/14 1:31 PM, Walter Bright wrote:
> On 1/17/2014 12:35 PM, "Ola Fosheim Grøstad"
> <ola.fosheim.grostad+dlang at gmail.com>" wrote:
>> On Friday, 17 January 2014 at 19:43:58 UTC, Walter Bright wrote:
>>> I've almost never had a problem tracking down the cause of a null
>>> pointer.
>>> Usually just a few minutes with a debugger and getting a backtrace.
>>
>> Doesn't work if the unexpected "null" sits in a graph and the source
>> of it is
>> hard to pinpoint or occurs "randomly". E.g. if you are using a "black
>> box"
>> framework or it happens spuriously on a server because it is triggered
>> by a
>> database timeout which never happens on the dev server.
>
> As I replied elsewhere, tracking down the source of a bad value in any
> variable is a standard debugging problem. There isn't anything special
> about null in this regard.

One problem with null is it's not "proportional response", i.e. it takes 
the application in the back and shoots it in the head instead of e.g. a 
stale display. That _does_ make null special; there's a large category 
of application for which aborting is simply not an option.

Andrei



More information about the Digitalmars-d mailing list