The Artima Developer Community
Sponsored Link

.NET Buzz Forum
How would you implement null argument checking

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Darrell Norton

Posts: 876
Nickname: dnorton
Registered: Mar, 2004

Darrell Norton is a consultant for CapTech Ventures.
How would you implement null argument checking Posted: Aug 17, 2004 1:17 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Darrell Norton.
Original Post: How would you implement null argument checking
Feed Title: Darrell Norton's Blog
Feed URL: /error.htm?aspxerrorpath=/blogs/darrell.norton/Rss.aspx
Feed Description: Agile Software Development: Scrum, XP, et al with .NET
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Darrell Norton
Latest Posts From Darrell Norton's Blog

Advertisement

Eric Gunnerson wants to know how we would like to avoid Null Argument exceptions.

I see this as related to Design-By-Contract. DBC has 3 checks: preconditions, postconditions, and invariants (both pre and post), so only 2 checks are needed and a mechanism to signify both to run. The Null Argument check is a precondition, or maybe an invariant. How is that related to AOP? Well, pre and postconditions are just code interception in one of the simpler models proposed by AOP proponents; messing with code at the beginning and end of the method is the very minimal AOP implementation. Many are more grandiose than that, being able to change code throughout the running of the method (or class, etc.). So perhaps the deeper question is how should C# support AOP, if at all? I'm not prepared to answer that. :)

A more pragmatic answer to Eric's question is what is the purpose of checking for null? I usually see it as a "developer exception", in that the developer accidentally sent you a null object when they were developing the application. In this case a NonNull attribute would be fine. How should this behave in a production environment? I would say the same. In fact, this implementation gives the developer metadata to check, versus just looking at the documentation or trial and error. So I'm all for the simplicity of an attribute!


This Blog Hosted On: http://www.DotNetJunkies.com/

Read: How would you implement null argument checking

Topic: IceRocket.com Search Engine Previous Topic   Next Topic Topic: Free Anti-Virus Software...clever marketing ploy or useful software?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use