Return-Path: Delivered-To: apmail-directory-dev-archive@www.apache.org Received: (qmail 96666 invoked from network); 1 Sep 2005 06:18:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Sep 2005 06:18:26 -0000 Received: (qmail 25388 invoked by uid 500); 1 Sep 2005 06:18:26 -0000 Delivered-To: apmail-directory-dev-archive@directory.apache.org Received: (qmail 25208 invoked by uid 500); 1 Sep 2005 06:18:25 -0000 Mailing-List: contact dev-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Apache Directory Developers List" Delivered-To: mailing list dev@directory.apache.org Received: (qmail 25193 invoked by uid 99); 1 Sep 2005 06:18:25 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Aug 2005 23:18:25 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [64.39.31.158] (HELO zeus.atlassian.com) (64.39.31.158) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Aug 2005 23:18:39 -0700 Received: from [192.168.0.44] (b128D.static.pacific.net.au [202.7.87.141]) (authenticated) by zeus.atlassian.com (8.11.6/8.11.6) with ESMTP id j816KKE17966 for ; Thu, 1 Sep 2005 01:20:20 -0500 Message-ID: <43169D2C.80109@atlassian.com> Date: Thu, 01 Sep 2005 16:18:20 +1000 From: Nick Faiz User-Agent: Mozilla Thunderbird 1.0.6-1.1.fc3 (X11/20050720) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Apache Directory Developers List Subject: Re: [OT] How best to respond to null arguments? References: <4315F5B2.1070406@bellsouth.net> In-Reply-To: <4315F5B2.1070406@bellsouth.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N I think the answer depends on the role of the class. If it's a client, or a "top level" manager, it's a good place to validate, rather than passing on crap information to further regions of code - IllegalArgumentExceptions are good for this (option #3) If it's a low level piece of code which isn't in charge of validating information it shouldn't have to think about it at all. (option #1). That's my 2 cents. Cheers, Nick Alex Karasulu wrote: > Hi all, > > I was playing again with my very many split personalities when I > realized one likes to throw NullPointerExceptions after checking if an > argument is null while another likes to throw IllegalArgumentExceptions > since null is value the argument can take. Yet another personality > does not care and figures a NPE will result anyway when the null > argument is referenced so why bother. > > Question: How best to respond to null arguments? > > Option #1: Ignore it and let a NPE result on its own > Option #2: Test to see if arg is null early and throw a descriptive NPE > Option #3: Test to see if arg is null early and throw a descriptive IAE > > Which sounds best? > > Alex > -- ATLASSIAN - http://www.atlassian.com/ Confluence - the enterprise wiki - tried it yet? http://www.atlassian.com/confluence/ --