You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lenya.apache.org by Felix Roethenbacher <fr...@apache.org> on 2009/02/09 21:30:51 UTC

Re: Spring Assert vs. Commons Validate

Andreas Hartmann wrote:
> Hi Felix,
> 
> froethenbacher@apache.org schrieb:
>> Author: froethenbacher
>> Date: Mon Feb  9 04:00:51 2009
>> New Revision: 742247
>>
>> URL: http://svn.apache.org/viewvc?rev=742247&view=rev
>> Log:
>> Started to replace deprecated Assert with Validate.
> 
>>  import org.apache.avalon.framework.service.ServiceManager;
>>  import org.apache.cocoon.util.NetUtils;
>> +import org.apache.commons.lang.Validate;
> 
> is there a special (functional) reason for using commons.lang.Validate? 
> Should we prefer it over the Assert class from Spring?

This is not a functional reason, but the Spring Assert class
is mostly used internally by the Spring framework (see javadoc).
Commons-lang's Validate is commonly used for argument validation
(throws IllegalArgumentException).

While replacing Assert's with Validate's I came across a few
Assert which were used in the sense of a Java 'assert' statement.
We should also fix this and use Validate for argument validation
only.

- Felix

> 
> Apart from the functional aspect, I think it is a good idea to use 
> Commons – we should rather create dependencies to Apache libraries than 
> to Spring.
> 
> -- Andreas
> 
> 


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


Re: Spring Assert vs. Commons Validate

Posted by Andreas Hartmann <an...@apache.org>.
Hi Felix,

Felix Roethenbacher schrieb:
> Andreas Hartmann wrote:
>> Hi Felix,
>>
>> froethenbacher@apache.org schrieb:
>>> Author: froethenbacher
>>> Date: Mon Feb  9 04:00:51 2009
>>> New Revision: 742247
>>>
>>> URL: http://svn.apache.org/viewvc?rev=742247&view=rev
>>> Log:
>>> Started to replace deprecated Assert with Validate.
>>
>>>  import org.apache.avalon.framework.service.ServiceManager;
>>>  import org.apache.cocoon.util.NetUtils;
>>> +import org.apache.commons.lang.Validate;
>>
>> is there a special (functional) reason for using 
>> commons.lang.Validate? Should we prefer it over the Assert class from 
>> Spring?
> 
> This is not a functional reason, but the Spring Assert class
> is mostly used internally by the Spring framework (see javadoc).
> Commons-lang's Validate is commonly used for argument validation
> (throws IllegalArgumentException).
> 
> While replacing Assert's with Validate's I came across a few
> Assert which were used in the sense of a Java 'assert' statement.
> We should also fix this and use Validate for argument validation
> only.

sounds reasonable. Thanks for the background info!

-- Andreas



-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01


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