Null Object design pattern instead of returning null
Posted by: Fabrice's weblog,
on 12 Feb 2009 |
View original | Bookmarked: 0 time(s)
This is just a quick post to make a plug for the Null Object design pattern. I don't think that it's used a lot, but it's useful to avoid a lot of issues.
It's very common to create or use methods and properties that return null. That's not surprising. It's part of most of the programming languages we use nowadays. However, returning null can lead to issues because if the callers forgets to test for null, it will likely provoke a NullReferenceException (or equivalent).
What the Null Object design...