From: "NAKAMURA, Hiroshi" Date: 2004-02-24T10:41:03+09:00 Subject: Re: Appropriate use of camelCase Chunky bacon! > From: "David A. Black" > Sent: Tuesday, February 24, 2004 9:51 AM > > Following the 'instance variable capitalization' thread, I'm convinced > > that I should be trying to learn the Ruby idioms. Now I just need to > > learn what they are. > > You can get at least a good rough idea from the source. From > /usr/local/lib/ruby/1.8: > > $ ruby -ne 'print if /\b[a-z]+[A-Z]/.match($_)' `find -name "*.rb"` | wc -l > 862 > $ ruby -ne 'print if /\b[a-z]+_[a-z]/.match($_)' `find -name "*.rb"` | wc -l > 19943 Hmm. 0$ egrep -r 'def +[a-z]+[A-Z]' lib lib/cgi.rb: def nOE_element_def(element, append = nil) lib/cgi.rb: def nO_element_def(element) lib/parsearg.rb:def printUsageAndExit() lib/parsearg.rb:def setParenthesis(ex, opt, c) lib/parsearg.rb:def setOrAnd(ex, opt, c) lib/parsearg.rb:def setExpression(ex, opt, op) lib/parsearg.rb:def parseArgs(argc, nopt, single_opts, *opts) lib/xmlrpc/create.rb: def methodCall(name, *params) lib/xmlrpc/create.rb: def methodResponse(is_ret, *params) lib/xmlrpc/httpserver.rb: def writeTo(port) lib/xmlrpc/parser.rb: def removeChild(node) lib/xmlrpc/parser.rb: def childNodes lib/xmlrpc/parser.rb: def hasChildNodes lib/xmlrpc/parser.rb: def nodeType lib/xmlrpc/parser.rb: def nodeValue lib/xmlrpc/parser.rb: def nodeName lib/xmlrpc/parser.rb: def parseMethodResponse(str) lib/xmlrpc/parser.rb: def parseMethodCall(str) lib/xmlrpc/parser.rb: def removeWhitespacesAndComments(node) lib/xmlrpc/parser.rb: def nodeMustBe(node, name) lib/xmlrpc/parser.rb: def hasOnlyOneChild(node, name=nil) lib/xmlrpc/parser.rb: def dateTime(node) lib/xmlrpc/parser.rb: def methodResponse(node) lib/xmlrpc/parser.rb: def methodName(node) lib/xmlrpc/parser.rb: def methodCall(node) lib/xmlrpc/parser.rb: def parseMethodResponse(str) lib/xmlrpc/parser.rb: def parseMethodCall(str) lib/xmlrpc/parser.rb: def startElement(name, attrs=[]) lib/xmlrpc/parser.rb: def endElement(name) lib/xmlrpc/parser.rb: def methodResponse_document(node) lib/xmlrpc/parser.rb: def methodCall_document(node) lib/xmlrpc/parser.rb: def createCleanedTree(str) lib/xmlrpc/parser.rb: def methodResponse_document(node) lib/xmlrpc/parser.rb: def methodCall_document(node) lib/xmlrpc/parser.rb: def createCleanedTree(str) lib/rss/xmlparser.rb: def startElement(name, attrs) lib/rss/xmlparser.rb: def endElement(name) lib/rss/xmlparser.rb: def xmlDecl(version, encoding, standalone) lib/rdoc/markup/simple_markup/lines.rb: def isBlank? 0$ (Only checked method name) Back to the topic, here is the coding convention for library which is bundled with ruby. [ruby-talk:62890], [ruby-talk:62894]. * use two-space indentation, no TABs * use RDoc * shouldn't use camelCase for variable names and method names * use camelCase for class names and module names * use upper case separated by '_' for constants Library users never want to mix under_scoer and camelCase. So, 1. Overturn the matz and rubyists's way, then rewrite all libs, or 2. Please use under_score name for users. Regards, // NaHi