avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Karasulu <aok...@bellsouth.net>
Subject Re: [VOTE] DefaultConfiguration.setAttribute(String,<null>)
Date Wed, 10 Dec 2003 19:45:32 GMT


> When DefaultConfiguration.setAttribute(key,value) is called with a null 
> as the value parameter, it should...
> 
>  1. ...throw a NullPointerException.

Makes no sense since null may be a valid attribute value which
equates to not having the value there in the first place.  These
situations are equivalent.

>  2. ...throw an IllegalArgumentException.

Again null is a valid value why would you complain if the API
user tried to do that.  Clearing values should be available 
functionality no?


>  3. ...act as if called with DefaultConfiguration.setAttribute( key, ""
> ). 
>        I.e. set the attribute to the empty string.

Bad move IMO.  If I set something to null I don't want it being 
replaced with a non-null empty string.  That could lead to several
bugs in code.  Users will test for null and the test will fail where
they expected a null value and code downstream will either freak or
worse yet cause a bug that's not detected until you're far away from
the region wheter the setAttribute() call was made.

>  4. ...remove the attribute if it exists.

I agree whole heartedly.  If I set something to null it should be
null its that simple.  Not removing the attribute would be like 
redefining what null means just for this specific API method.  Again
IMO this is not a good practice.

> My vote is for 4. Why? Because setValue(null) removes any existing
> value from a DefaultConfiguration.

+1

Alex



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Mime
View raw message