Talk:Introduce Null Object
From CSSEMediaWiki
Another possible method of dealing with a constructor that may fail (return null) is to make the constructor private. Then we just need to create a static method that does the work of the constructor. In this way if the construction of the object fails then the static method can just return a null. A quick null check of the result will let you know if something has gone wrong. What do you think of this take on the problem? -- Oliver Cardwell 01:49, 21 October 2010 (UTC)