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...

Advertisement
Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.
Category: Refactor | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 1745 | Hits: 265

Similar Posts

  • Using the ObjectContainer in disconnected scenarios Part 2 more
  • Exposing Custom WCF Headers through WCF Behaviors - Part 2 more
  • New Agile Boot Camp Dates (March 11-13) more
  • Identity Maps more
  • No Empty Selector in jQuery more
  • GeoRSS Editor alpha version is up and running more
  • EF: GetRelationTypeExpensiveWay more
  • What's for VB.NET in the Future, interesting to see... more
  • Injecting Typemock Stubs and Mocks using the StructureMap container in a unit test more
  • ObjectQuery, LINQ to Entities and IQueryable more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD