2010/7/27 Peter Neubauer <peter.neuba...@neotechnology.com>

> Hi all,
> I just stumbled over the immutable TraversalDescription API
> (http://components.neo4j.org/neo4j-kernel/apidocs/index.html), which
> will not modify the object if you do
>
> TraversalDescription td = new TraversalDescriptionImpl();
> td.depthFirst();
>
> Instead, one needs to reassign td, like
>
> TraversalDescription td = new TraversalDescriptionImpl();
> td = td.depthFirst();
>
> However,
> TraversalDescription td = new TraversalDescriptionImpl().depthFirst();
>
> will give you the expected td.
>
> IMHO this is unexpected behaviour and hard to get if you just follow
> the common fluent API and presume a Builder-pattern. Especially since
> no errors are thrown and you just end up with strange results and
> unreachable code i e.g. a custom PruneEvaluator etc. True, the API
> says it is immutable, but still I think this is hard.
>
> WDYT?
>
> Should we think of changing this to a proper builder.modify().modify
> etc and finally builder.build() wich gives you the final, immutable
> instance of TraversalDescription and is clearly understandable by
> clients?
>

I still think the current approach is more useful (although it'd be nice
with more input on this). One reason I think it's better is that you can
half-bake descriptions as private static final or similar and then complete
the descriptions in several different places in your code. You can even pass
in descriptions in methods and what not, without any risc of them being
modified. I think javadoc should better explain this and it should be
expected that developers read javadoc, right?


>
> Cheers,
>
> /peter neubauer
>
> COO and Sales, Neo Technology
>
> GTalk:      neubauer.peter
> Skype       peter.neubauer
> Phone       +46 704 106975
> LinkedIn   http://www.linkedin.com/in/neubauer
> Twitter      http://twitter.com/peterneubauer
>
> http://www.neo4j.org               - Your high performance graph database.
> http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party.
> _______________________________________________
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Mattias Persson, [matt...@neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com
_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to