couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark J. Reed" <markjr...@gmail.com>
Subject Re: JSON style question
Date Fri, 25 Mar 2011 14:44:45 GMT
There's clearly a happy medium between
"thisIsMyLoopControlVariableForTheOutermostOfThreeLoops" and "i".  :)

The important thing is to be consistent.   It may make sense to ask
about a standard for JSON style, but remember that  while JSON syntax
is based on JavaScript, its purpose is to be a language-agnostic data
transfer format.  Sure, Java and JavaScript programmers tend to use
camelCase, but Python and Ruby programmers tend to use snake_case; so
if you're transporting data between code written in languages with
different styles, which style should you use?

Personally, I like to use hyphens (words-like-this) whenever I can get
away with it; most programming languages don't allow them in
identifiers, but a key in a hash/dict/object is just a string.  Then
again, there's often a shorthand syntax for literal strings that
happen to match identifier syntax (obj.key instead of obj['key'] in
JavaScript, :sym instead of :"sym" in Ruby, etc.), which you lose out
on by using hyphens.

-- 
Mark J. Reed <markjreed@gmail.com>

Mime
View raw message