Calling a parent component function from within a child

One of the three pillars of OOP is encapsulation. This means to keep information within the object and make it only accessible through an API (getters and setters or similar).

If you now pass a ValueTree and traverse in each object to arbitrary places, you circumvent the API and you can alter any data from anywhere. So one of the great benefits of OOP is gone, and to find where data was altered you need to revisit all your code instead of only the object where that information was intended to be.

But there are exceptions like everywhere.
I use e.g. ValueTree for a video DAW (NLE), where each node in the ValueTree represents an object in my audio pipeline. In that case I store the node in the object and force myself not to traverse to the parents etc.
Or the same I use in my PluginGuiMagic. It’s the best way to get Undo/Redo implemented properly.

ah! good thing C++ isn’t a pure OOP language! :wink: But seriously, my approach maintains the encapsulation with the domain specific ValueTree wrappers. ie. clients of the data don’t do actual ValueTree operations at all, they only access the data through the wrapper class. which can do any need validation, constraints, etc. this also means I can change the underlying data storage if I wanted to (mostly, lol).

To say this a different way, my ValueTrees are the Data Model, and the Front End and Back End use these wrapper classes for interacting with that data model.