directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lecharny <elecha...@gmail.com>
Subject Re: Should we use assert ?
Date Fri, 04 Jun 2010 12:22:11 GMT
On 6/4/10 2:16 PM, Felix Knecht wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 06/04/10 12:15, Emmanuel Lecharny wrote:
>    
>> Hi guys,
>>
>> currently (and probably because nobody uses them, due to some Java 1.3
>> habits we have), we don't use asserts to do simple things like checking
>> methods parameters (pre-conditions).
>>
>> Should we start using them ?
>>      
> +1
> Just make sure, that assert isn't used in places where it's
> shared/apacheds/... specific as an AssertationError is thrown in case.
>    
See my other mail about when to use asserts or not (ie, User API should 
not use them)

> What about error messages? Do we need them here? If so it can blow up
> the code, just imagine something like
> assert ( ( value instanceof String ) || ( value instanceof byte[] ) ) :
> "String or byte[] expected instead of " + value.getClass()
>    

Yes, assert must be used with a message.
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.15 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkwI7rUACgkQ2lZVCB08qHEFLQCfSzuVCIOGenudn7TExxLO/2EL
> 7JIAoIOuHtV2fqafEsVQLnkTjo+mFEpZ
> =QAuM
> -----END PGP SIGNATURE-----
>
>    


-- 
Regards,
Cordialement,
Emmanuel L├ęcharny
www.nextury.com



Mime
View raw message