First of all, not sure about the title of the topic here. Sorry if it doesn't really corresponds to what I'm asking.
I'm in a situation where I have some ideas but all I don't know if one of them is better then another and maybe I'm missing something. Here is the thing :
Currently I have one instance A which creates an instance of another class B, and use callbacks from instance B (via a callback class which is implemented by class A), and use this callback to notify another instance of a class C, also created inside of class A and private. Here is a summary diagram :
Now, in the future, for some reason, it is another object, of class D, which needs to create and keep the object of class B. The issue is that the object C still need to be notified when I have callbacks from B object. And of course, the C instance cannot move from A to D. So, from D, I haven't A instance nor B instance, and I don't know the best way of doing it. Here is another diagram with the D class :
This is basically the same as the first diagram, except that the last call (notifySomething()) is hypothetical since I don't have access to the C instance from the D class.
Does someone ever faced this situation and what is the best way of resolving it ?
Thanks !