Best practise for defining data structures with ValueTrees?

I’m wondering which one is a better approach to use ValueTrees when you have different kinds of classes that use their data:

  1. Node contains a property which tells what kind of data it contains. The ValueTree type Identifier is the same for all nodes.

  2. Node’s Identifier itself tells what kind of data the node contains inside of it. No need for specific property to exist inside the Node so classes can figure out what kind of data they should expect the node to contain.

If there’s even a better approach, I’d like to hear that one too.

In case you haven’t already seen it < David Rowland - Using JUCE value trees and modern C++ to build large scale applications (ADC'17) - YouTube >.

At first view I would vote for choice 2!

It’ll depend on what sort of data you’re storing as to what shape the tree will take.

I see ValueTrees/XML as an object-oriented data structure, where each node in the tree represents some object, and that object has a set of attributes. SO what objects you have will depend on what the data is you’re storing.

2+

OK sounds good. Another related question:
Does ValueTree and TreeView have anything to do with each other? My guess is that they are completely unrelated?

Totally unrelated. One’s a data structure, the other is a UI element (a juce::Component).

They use a similar concept of a tree, what with a parent and child relationship.

OK, thanks!