ValueTree property naming best practices

I’m wondering what is the best practice as far as a naming identifiers used in the ValueTree?

For example I have two different node types in the tree, SYNTH and OUTPUT. Each one of them has an index property. Should I create two different identifiers, SYNTH_IDX and OUTPUT_IDX or is it fine to just use a single identifier called IDX? Would there be downsides to that when trying to differentiate between them in the property changed listeners, or maybe in other scenarios?

So long as you check the ValueTree type before comparing any property IDs, I think there wouldn’t be any problems with using the same Identifier object. I’d prefer to create separate IDs just to avoid that being a potential source of errors, though.

I like to use different namespaces for each type of ValueTree node. Something like:

namespace SynthIds
    static const juce::Identifier SYNTH ("SYNTH");
    static const juce::Identifier index ("index");

namespace OutputIds
    static const juce::Identifier OUTPUT ("OUTPUT");
    static const juce::Identifier index ("index");

As you can see, I also like to use different casing styles for ValueTree ids and property ids, but that’s just personal preference.

I use PascalCase/TitleCase for types and camelCase for properties. Full uppercase reminds me too much of HTML :slight_smile:


I use this same convention

My question was more about the actual names of the properties, not the casing :slight_smile:

Ah yes I see now. Yes I would reuse the same properties across different types.