When to use constants?

I do not remember well what is the difference in using a constant, loading the value directly. The result in XOD is the same, when should it be used?

const

Hello @cesars!

Sometimes I like to see the values in the patch. I use constants for this. It is more comfortable for me then clicking on the nodes and have a look on the inspector.

2 Likes

Times it probably makes more sense to use constants instead of just typing values into the node:

  1. You want to see values in the graphical patch easily (as stated above)
  2. You want to use the same value for multiple inputs
  3. You want to make it obvious what values are to be changed to customize a program (constants could be grouped in an area with comments instead of having to open each node to select values to change)

I don’t think there is ever a time you “need” to (or should) use one option over the other; it is just a preference choice. I generally avoid constants unless there is a reason to use them, but I am more likely to use them for examples where I will just post a picture of the node so values are obvious. In your example, the node name makes it obvious, so adding constants is redundant. Using node names gets annoying if the value changes frequently since you have to change label & value.

3 Likes

Thanks for the answers :+1:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.