Advice for naming reactive expressions

I'm writing some Shiny training content for beginners and I'm interested to hear views on the following advice for naming reactive expressions:

Use verbs rather than nouns to name reactive expressions, e.g. getData rather than data.

I'm thinking this will help prevent the common mistake of forgetting to call the reactive when using it, and also reinforce the idea that a reactive expression is more like a function than a variable.

Some of the RStudio examples use nouns instead of verbs, so I'm concerned I'm missing something and potentially giving bad advice!

I would love to hear your feedback.

1 Like

I tend to use nouns. I realize it's extremely unusual to call a noun as a function. But then, reactive expressions occupy a grey area of state and behavior. I like to deemphasize the behavior part because it's so dangerous to put side effecty code in the reactive expression, and dangerous to expect it to be actually executed when you call getData().

It's an interesting point you make though about helping people remember to use ()! I'll chew on that!

2 Likes