Are there any guiding principles of OO design to take into account when deciding which of two interacting and linked objects should be included as a component into the other (or referenced from it)?
For example, I am trying to realise the A* shortest path search algorithm with classes and objects. Besides a given graph, I plan to have a
DataFlow object and a
Controller object. I plan the
DataFlow object to be responsible for maintaining the state of knowledge about the shortest paths found so far and for propagating improvements from nodes to their neighbours. I plan the
Controller object to be responsible for the graph exploration strategy and to make it configurable with any of a number of strategies (A*, Dijkstra, greedy, etc.).
After some thought, I've decided that the
DataFlow object is going to receive and store the
Controller object during initialisation, but I cannot explain clearly why this would be better than the other way around.