On 30.7.12 15:02, Alexander Klimetschek wrote:
On 20.07.2012, at 14:58, Julian Reschke <[email protected]> wrote:
On 2012-07-20 14:41, Alexander Klimetschek wrote:
On 20.07.2012, at 09:01, Julian Reschke wrote:
I agree with that, but that's how JCR works.
Well, you have both options: if you use the has*() or
(item|property|node)Exists() methods, and since PNFEx inherits from
RepositoryEx, you can skip the try/catch for the application logic.
That "works", but causes lots of unneeded work in the implementation;
which is exactly why I started this discussion.
Yes, but this is one of the things that the infrastructure (i.e. JCR) should
provide (without a penalty) instead of having to handle this again and again in
your application or use ugly exception handling.
But I agree that a get<Something>() returning null if it's not existing is also
a very good idea, currently lacking from JCR.
An even better way to handle this is to return an Option<T>. Guava has
something along these lines [1]. Unfortunately Guava's version of Option
is not a monad which makes it not as useful as it could be.
Functional Java has a more complete implementation [2].
Michael
[1]
http://code.google.com/p/guava-libraries/wiki/UsingAndAvoidingNullExplained
[2]
http://functionaljava.googlecode.com/svn/artifacts/3.0/javadoc/fj/data/Option.html
Cheers,
Alex