|
The best approach in cases like these is to make the subgraph explicitly reveal the ports it offers to the parent object. Compare the subgraph to a function in a programming language: it has its contents, but also a name and list of parameters that it reveals as its signature. That has proven to be the most efficient, solid solution.
At the moment, your PropConnector objects have no name of their own, but instead reveal the name of the port on an object in the subgraph (e.g. Src on SetStartLocation). If we follow the analogy of a function, the PropConnector should be able to set its own name, which allows better specification of the semantics of the port in the context of this graph. We could consider the signature to be (StartSrc, StartDest, TargetSrc, TargetDest). It's better that those are explicitly revealed and named — rather than just being "any port I haven't connected yet", revealing and creating a strong coupling with the internal details of the sub-object name (SetStartLocation), and a port within its subgraph (Src).
Often, we want our languages to be scalable, allowing multiple levels of subgraphs. If we make the name displayed in an object's port to be the name of a object's port in a subgraph, then we have to ask where that lower port got its name. Presumably from a subgraph; obviously that chain has to end somewhere, with the lowest subgraph no longer connecting its port to another object with ports, but instead to an atomic object. That object will be a literal value like '3' or a local variable - and neither of those are well-suited to be the name of a port several layers higher. It's cleaner and more scalable to put the name into the 'formal parameter' - your PortConnector, which is an example of what we often call 'interface objects'.
This approach also lets you connect an interface object in the subgraph to several ports - the modeling equivalent of using a function parameter in more than one place in the function body. That's very common, and shows up another problem if the naming is taken from the subobjects' ports: if an interface object is connected to two ports with different names, which one wins?
Your example graph above probably doesn't have all these issues, and may never need to scale up and face them. Still, these are good general principles that we've found, and hopefully give you some useful points of view to think about.
|