(First of all, I am sorry if you all got more then one copy of my previous mail... problem with my mail-account...)
Thanks for your thought! I agree, but I'm still uncertain of what I think is best... I just get this feeling, you know? It might be that I deep down use the metaphor of a value object when I look at a node, and that the expected behavior of a value object is to get null back if I try to get a property that isn't set. Or maybe I feel that the default should be that your domain logic/model should decide if your code should fail miserably, and not the persistence. Or maybe it's just me! Any other thought on the issue are welcome :) I totally agree that the method with the default value is great! No question about that, and of course I use it return other things than null as well :) Best, Mattias Ask 2010/1/5 Mattias Persson <matt...@neotechnology.com> > Well, I think it's generally a good thing to be able to distinguish > mandatory stuff from optional stuff... and that's the use case of > those two methods. > > If you're getting a property which "must" be there in your domain you > shouldn't have to check for null in all those cases, it feels so > C-like to me... it should just return my value or else fail miserably > so that I can see right then and there that there's a bug in my code > (in this case the code which created my domain object or similar). > > And the one with the default value is great since I find myself > passing in other things as well, not just null. I just couldn't live > without any of them really. > > Just my point of view on this... > > 2010/1/5 Mattias Ask <mattias....@jayway.com>: > > Hi everyone, > > > > I have an issue which I would like your opinion on... It's mostly a > question > > of code aesthetics, to be honest, but still... > > > > When I look in my code I see myNode.getProperty(SOME_PROP, null); > > everyehere... The reason for this is that I if I called > > myNode.getProperty(SOME_PROP) I'd have to check for org.neo4j.api.core. > > NotFoundException everywhere that I read properties that are not > mandatory. > > What if myNode.getProperty(SOME_PROP) was to return null instead? The doc > > says explicitly that you can't persist null. If > > myNode.getProperty(SOME_PROP) where to return null this would mean, > without > > any doubt, that the property does not exist, right? The upside to this > would > > be that I wouldn't have to use the DefaultReturnValue null everywhere. > And > > the argument that I'd have to null-check everywhere is kind of moot since > I > > already return null as DefaultReturnValue. > > > > In my case my domain objects extend a NodeDelegate, which takes an > > underlaying node in the constructor. This means that I can use > > getProperty(SOME_PROP, null) everytime I call getProperty(SOME_PROP)... > but > > the question is if there are any downsides to doing that? What are your > > thoughts on this? > > > > Best, > > Mattias Ask > > _______________________________________________ > > Neo mailing list > > User@lists.neo4j.org > > https://lists.neo4j.org/mailman/listinfo/user > > > > > > -- > Mattias Persson, [matt...@neotechnology.com] > Neo Technology, www.neotechnology.com > _______________________________________________ > Neo mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > _______________________________________________ Neo mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user