Neo4j matches my mental model of information

I’m a visual person which means that I see pictures in my head when I think about abstract things like structure, code and information. My guess is that most people do, but anyway…

When I first started looking at Neo4j I was blown away by how precise the graph database structure matched my mental model of information. You have blobs of informations (nodes with properties) that relates to other blobs of information. Perfect!

When I started playing around with the API I couldn’t do what I wanted, namely extend NodeImpl and make the objects I want to persist Nodes. Now, Neo4j has a very nice API which is hard to abuse (if you don’t place your classes in the same namespace as they use), and understandably they don’t want you to extend NodeImpl. The design guide gives this example of use:

That’s great, but it doesn’t match what I see in my head… In order to make things match I made a subtle change.

By doing this I can work with my domain objects as Nodes. I don’t know if it is “correct” but with this small change I can say that “A Customer IS a Node” and this is what I see in my head. Good? Bad? You be the judge, but it fits me :)

This Post Has One Comment

  1. I like the idea of having domain objects abstract the persistence layer away, which is what you have achieved – nicely done. Don’t you have to implement delegate methods for all in the Node interface though? There’s quite a few!

    Extending an implementation of Node would be preferable but not sure this is exposed via the API. If this were possible you could have extendable Node types which have their own typesafe properties and methods.

Leave a Reply

Close Menu