jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting" <jukka.zitt...@gmail.com>
Subject Re: use of java 1.4 assert
Date Thu, 23 Feb 2006 09:43:11 GMT
Hi,

I agree with Marcel's points. Using assert is not appropriate for
public methods like the JCR API and the o.a.j.api interface, as we
cannot control the code that accesses those methods. We can however
control the internal Jackrabbit code, and using asserts is a good way
to more strictly enforce the internal method interfaces.

Regardless of the performance points, my guideline for using assert has been:

 * if a method is only called from within the same source tree,
   use assert for preconditions
 * if a method is called by external components,
   explicitly check arguments and throw normal exceptions for preconditions

I'd also be happy to see assert getting gradually used also for things
like postconditions and loop invariants in the more complex methods.

BR,

Jukka Zitting

--
Yukatan - http://yukatan.fi/ - info@yukatan.fi
Software craftsmanship, JCR consulting, and Java development
Mime
View raw message