Talk:Null Object pattern
|WikiProject Computing / Software||(Rated Start-class, Mid-importance)|
Strange "contradictory" intro statements for examples
- 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).
Missing example: Qt
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
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)
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
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". 188.8.131.52 (talk) 22:05, 12 March 2013 (UTC)