For context, I'm building a GTK+ application in C where a subclass of GtkApplicationWindow creates and displays a subclass of GtkToolbar and a GtkNotebook (a widget with multiple pages that can be displayed alternately by a member function). There are radio buttons on the toolbar to switch among the pages.Should the toolbar hold a (duplicate) reference to the notebook (provided by the window during construction), or should it only hold a reference to its owner (the window) and call a function of its owner which in turn calls the notebook's function to switch pages? Another alternative, the toolbar might only keep a reference to window, and access the window's reference of the notebook each time it wishes to toggle pages? I have a feeling this is a case addressed by the Law of Demeter, but I'm not sure what it dictates.
Should an object keep a reference to a sibling object, or access through mutual owner's method
design patterns;object oriented design;patterns and practices;gtk;law of demeter
It should only hold a reference to its owner (the window) and call a function of its owner which in turn calls the notebook's function to switch pages.  The owner owns the reference to the notebook and can validate whether the pointer is still good vs. has been released.