DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=34098>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=34098





------- Additional Comments From [EMAIL PROTECTED]  2005-07-08 17:49 -------
(In reply to comment #2)
> about throwing an exception. as you've mentioned in getShort() you must throw 
> an 
> exception. then why not throw it always?

This is just a matter of choice, some people prefer not to wrap the calls to the
configuration into a try/catch block and let the code break with a
NullPointerException or a NoSuchElementException at runtime.

> this will have the benefit of allowing 
> a user to set a property to null if he wishes.

Something that [configuration] doesn't support currently, a null property is
equivalent to a non existing property.

> if that user wishes not to get an 
> exception, the rule is simple: use getProperty(key, null). in fact, i would 
> discourage the usage of getXXX(key) methods, maybe even removing them 
> altogether. the best approach is to always have the client tell you what the 
> default value is, rather than guessing it.

I agree that providing default values is a good practice, but here again some
people find it more convenient not to care about it, we try to support both
concepts.


I suggest the following changes in order to improve the consistency of the API:

- throw an exception on calling getXXXArray() or getXXXList() for a missing
property when isThrowExceptionOnMissing is set.

- add a getObject(String key) method similar to getProperty() but throwing an
exception for a missing property when isThrowExceptionOnMissing is set. 

- add a getObject(String key, Object defaultValue) method.



-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to