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?

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

Reply via email to