Names of Spatial objects

The javadoc says that the name of a Spatial object is required for identification and comparision purposes.  Does it matter if two different Spatial objects have the same name?  I'm a little unclear how these names are being used.

I believe that the names are purely a user convince.  HOWEVER, just because you can instantiate an object like this: Sphere sphere = new Sphere(); but be aware that this leaves the name String = null.  So if you are doing any searching through nodes for a name, then it will result in a null exception error if it encounters this node.

this will work: Sphere sphere = new Sphere( "" );, because an empty Sting is not a null String

To add to what basixs said, if you have plenty of children in a node and want to perform a specific function on a certain child of that node, then one way of doing it is:

Node parent = new Node("Parent");;

Box Child1 = new Box("Big box");
Box Child2 = new Box("Small box");


if(parent.getChild("Big box").hasCollision(player, false)
         //Do Something

If you had same names or as basixs pointed out, null, then you would not have this option. So while it might seem pointless now, it could be quite useful down the line to give Spatial objects different names and it is generally good software engineering practice to do so.

IMO: names should be used for debugging only! (there still are some cases where you don't have another choice, though)

So, if you have the chance, use names to identify them as a developer, don't use them to identify them in the program (in contract to what hawk2k8 suggested).

Thanks for those comments!  I think I understand a bit better now.

IMO: names should be used for debugging only! (there still are some cases where you don't have another choice, though)

Out of curiosity, and agreement, is it possible to use collision callbacks without checking node names?  How I am using it right now is to just like the ContactCallBackTest, however it would seem to make more sense to add the callback directly to the node itself.  But I don't think this is possible.

Oh Yes, the Funny ContactCallBack.

For Example:

I've made a CollideAble Node with a special Collision method.

than in the ContactCallback I ask the getParent of both CollisionNodes, if its "instanceof" the CollideableNode.

when true the Collisionmethod is called.

Now avery PhysicsNode need its own parent, but till now I haven't found a better idea for JMEPhysics