Hi everyone,
I was playing right now with the index api to do some fulltext search, and I
found something what I think is not good for the API.
The index API rely heavily on Strings, just like the following:
Index<Node> typeIndex = index.forNodes("places");
I do write the call to forNodes method all the time I need to use it, like
when creating and when searching with this index and sure, probably I could
do it better, like isolating this on an application scoped component. Thus,
the "places" String got spread all over my code. And then, guess what, I've
made a mistake naming my index. I had to hunt down every "places" String on
my codebase (at this stage it isn't large, but for some other people this
can be).
My suggestion is to work with something similar at what is done at the
Relationships, with the RelationshipType interface. I never use Strings when
creating relationships, only enums who implements the interface, and I can
easily refactor it.
As pointing a problem (at least in my point of view) is good, suggesting a
solution is better :D. Then, my final suggestion would be to create an
interface to the index definitions, like IndexDefinition, and do an overload
at the forNodes method, that can receive the definition
(forNodex(IndexDefinition)). It will only delegate to the forNodes(String)
method, using the enum, so one can stick with it, if is already using it.
Of course, I don't know if you guys think that being refactor friendly is an
major issue for an API, if not, just ignore me ;).
Best regards.
--
Adriano Almeida
Caelum | Ensino e Inovação
www.caelum.com.br
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user