Should the json keys be camelCased or underscore_cased? It's a bit ambigious.
Should the json keys be camelCased or underscore_cased? It's a bit ambigious.
doc.set({related_article : 'http://...'});
Even though you might have: doc.openRelatedArticle();
As a method on the JS model. Definitely less than ideal.except if you're trying to subtract:
c = a-b
which is why languages with arithmetic don't allow '-' in variable names. (Then function/method names get the same rule. KISS.)Basically, I try to follow the conventions of whatever language I'm working in because that just makes it easier for people working in that language to incorporate your lib.
And yes, lowerCamel seems to be the default for JS.
For a JSON wire protocol it's different, because it's not a language specific API that you're exposing, it's a protocol, which is a different beast.
For text-based wire-protocols I prefer to 'ignore' case (because of ambiguity) by sticking with lowercase all the way. Names need separators and the underscore works nicely for that everywhere.
Keys I use for sending over the wire therefore follow the Ruby style.
o["foo bar"]
You know, actual spaces? Spaces don't make for valid variable/method identifiers in most languages, yes, but it's not like keys you received from the network should be leaking into your identifier namespace anyway—that's how MITM attacks start.But often times it is used exclusively (or in majority) on the server-side. If the server side language follows the underscore_case convention. That's where the ambiguity creeps in.