Ruby - Naming Convention - letter case for acronyms in class/module names?

前端 未结 3 2077
失恋的感觉
失恋的感觉 2021-01-04 01:20

I need to create a class that represent \"SVN\" inside a module called \"SCM\". But I don\'t know what is the convention when dealing with acronyms in Ruby, and could not fi

3条回答
  •  春和景丽
    2021-01-04 01:51

    SCM::SVN looks best to me. Rails is full of classes like ERB, ORM and OMFGIMATEAPOT. And that's not to mention things like JSONSerializer. Ruby's source has a bunch of acronyms, too. The most obvious example to me is YAML. The standard as I've seen it is to upcase letters for CamelCase but generally not to downcase them (although Rails has opinions on model names).

    If you have grep and the source code you can see plenty of examples with something like

    grep -r 'class [A-Z]\{3,\}' 
    # or, if you only want acronyms and nothing like YAMLColumn:
    grep -rw 'class [A-Z]\{3,\}' 
    

提交回复
热议问题