Adding property naming standards to the MNX documentation #304
Replies: 3 comments 4 replies
-
I've never heard kebab case. Hilarious! So perfect. My recommendation has been underscore case for three reasons: (1) it's been shown to be easier for non-native English speakers to read. (2) it's easier to use in case insensitive contexts. (3) it helps blind developers using screen readers. The pros of camelCase are two: (1) save a character. (2) more JavaScript native and that's what the J in Json means. I feel like the pros of helping diversify who programs (underscore case) outweighs saving a byte. |
Beta Was this translation helpful? Give feedback.
-
Given the "JS" in "JSON", it is essential to make the switch from const layouts = score.getLayouts(); // get the layout of a score JSON object
const {name, multimeasureRests} = layouts[0]; // unpacks properties of furst layout into variables The above obviously works with underscore properties too, but not with anything like |
Beta Was this translation helpful? Give feedback.
-
Camel case gets my vote as well (thanks to the various research/arguments in this discussion thread). The one thing I'd add is: we should endeavor to sidestep the issue whenever possible. That is, we should prefer one-word property names except in cases where a one-word property name can't be avoided. |
Beta Was this translation helpful? Give feedback.
-
Would it be helpful for us to add a section to our documentation with naming patterns/standards for object properties?
For example:
kebab-case
vs.camelCase
vs.snake_case
(In XML we tended to name elements and attributes with kebab case. In JSON, camel case or snake case is more common – do we need to switch?)Beta Was this translation helpful? Give feedback.
All reactions