Talk:Null Object pattern

From Wikipedia, the free encyclopedia
Jump to: navigation, search
WikiProject Computing / Software (Rated Start-class, Mid-importance)
WikiProject icon This article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
Start-Class article Start  This article has been rated as Start-Class on the project's quality scale.
 Mid  This article has been rated as Mid-importance on the project's importance scale.
Taskforce icon
This article is supported by WikiProject Software.
 

Strange "contradictory" intro statements for examples[edit]

  • the C++ example "illustrates how the pattern is more complicated with types"
  • the C# example shows how it can be properly implemented (this properly implemented seems to imply the example before is not proper, it however is almost identical).

Kasterma (talk) 17:48, 2 October 2014 (UTC)

Missing example: Qt[edit]

This article should mention the Qt framework. AFAIK, It is the only widely-used C++ library that implements null objects consequently. Ever wondered why the Qt framework uses neither exceptions nor C-style error codes? It is solely because of proper use of Null objects. Vog (talk) 16:23, 4 June 2014 (UTC)

Disagree with the article's statement[edit]

This article is completely wrong. Null pointers and Null variables have little or nothing to do with the Null Object design pattern. http://www.cs.oberlin.edu/~jwalker/nullObjPattern/

Maybe I phrased things badly - my understanding is that one reason for the pattern is to avoid the checking needed to make sure a variable doesn't have a Null pointer or value as these add to the complexity of code, making it harder to maintain. If I'm mistaken, I'd gladly like to learn better. Autarch 12:23, 28 September 2007 (UTC)
Upon reading the article, I thought that you were saying that we were using 'null' varaibles and checking whether they were 'null' each time we used them. If I understand correctly, the Null Object Pattern is actually about an object which implements default behavior in absence of something else. For instance, an implementation of an interface whose methods bodies are empty. The article is bad, but strangely it has excellent external links to flesh out a fair article. Ruijoel 13:06, 25 October 2007 (UTC)
Apologies for badly phrasing things in the article - I'd got information from secondary sources - any flaws are my fault, not theirs. Autarch (talk) 16:12, 14 January 2008 (UTC)

I think a better example is that of a logger. Often you see code if logger != null then logger.log ( message ). With the null object pattern you then have a NullLogger which just ignores the input and you get logger.log ( message ). Also, often these null subclasses are singletons (since ignoring everything is often stateless). CaptainPinko (talk) 19:29, 10 May 2010 (UTC)

It looks like the article has been updated, as the content is correct now. The examples are still bad, though. The C example misses the concept entirely (the pattern requires the concept of objects, so I don't know that this pattern can be implemented in C) and while an empty C# array may exhibit similar behavior to a null object, it certainly isn't a good example of the practical use of the pattern. Bgano (talk) 22:35, 18 April 2011 (UTC)

Criticism of Criticisms[edit]

I have not read "Fowler, Martin (1999). Refactoring pp. 261", but the "Critisism" section is very weak and lacking of any actual criticisms. There is no value in saying "this may cause bugs, as references this source". 202.65.14.164 (talk) 22:05, 12 March 2013 (UTC)