The essence of polymorphism is that instead of asking an object what type it is and then invoking some behavior based on the answer, you just invoke the behavior. The object, depending on its type, does the right thing.

from http://sourcemaking.com/refactoring/introduce-null-object

The basis for this pattern is that instead of checking to see if null objects, you create a prototype object, with a “IsNull” property, and instead of checking to see if its null, you would check this property.

To be really honest, im not sure why you would do things this way. This seems like a really convoluted way of basically doing nothing at all. The code samples show that instead of doing object == null, you do object.IsNull. What is the point of that?

This method of doing this is counter intuitive. If the database cannot find the user, why should it return an empty object and set a property to say that it SHOULD be null? If it SHOULD be null, why not set it to null?

In my opinion, this is an antipattern, not a pattern.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • DotNetKicks
  • DZone