accessibility of an object created in a plugin, from the header

I don’t know if this is the right way but by reading here , I have tried the following : added a global $MyObject in functions.php just before I create the object, and then put a global $MyObject in the header-menu.php file. This works : the object is now visible.
Unless someone knows a drawback doing this, this could be the answer…