Intact Interconversion
Intact Case is the rules for natural interconversion of compound words which including an acronym in camelCase and snake_case. By adding one rule when converting, it enables mutual conversion while keeping the information of separate words and capitalization of an acronym.
camelCase ⇒ snake_case
# | Procedure | Actual Example |
---|---|---|
0 | original camelCase | getUTCDay |
1 | tokenize | get + UTC + Day |
+ | add a delimiter to after each acronym | get + UTC_ + Day |
2 | all words to lower case | get + utc_ + day |
3 | concatenate with between delimiter | get_utc__day |
snake_case ⇒ camelCase
# | Procedure | Actual Example |
---|---|---|
0 | original snake_case | get_utc__day |
1 | tokenize by delimiter [1] | get + utc_ + day |
2 | capitalize each word except first | get + Utc_ + Day |
+ | If last letter of the word is a delimiter, remove the delimiter and to capitalize all letter of the word. | get + UTC + Day |
3 | concatenate | geUTCDay |
[1] When two delimiters are successive, proceed as follows.
- first one is as a part of previous token.
- second one is used as delimiter to tokenize.
When delimiter is at the end of the entire compound words, it means "added for the acronym".
In Case of Successive Acronym
XMLHttpRequest is a familiar class name in the Javascript of Ajax. HTTP is acronym, therefore to tokenize XMLHttpRequest should be as follows.
But if to concatenated them simply as all uppercase XML and HTTP, can not seperate the compound words of XML and HTTP. The readability is not kept.
Examples for Unreadability
XML + HTTP + Request | XMLHttpRequest |
parse + DBM + XML | parseDBMXML |
TCP + IP + Socket + ID | TCPIPSocketID |
In Intact Case, if compound words has two or more successive acronyms, to use delimiter between them.
XML + HTTP + Request | XML_HTTPRequest |
parse + DBM + XML | parseDBM_XML |
TCP + IP + Socket + ID | TCP_IPSocketID |
This rule allows natural interconversion of camelCase and snake_case, which including some acronyms.
camelCase ⇒ snake_case
# | Procedure | Actual Example |
---|---|---|
0 | original camelCase | XML_HTTPRequest |
1 | tokenize | XML + HTTP + Request |
2 | add a delimiter to after each acronym | XML_ + HTTP_ + Request |
3 | all words to lower case | xml_ + http_ + request |
4 | concatenate with between delimiter | xml__http__request |
snake_case ⇒ camelCase
# | Procedure | Actual Example |
---|---|---|
0 | original snake_case | xml__http__request |
1 | tokenize by delimiter | xml_ + http_ + request |
2 | capitalize each word except first | xml_ + Http_ + Request |
3 | if last letter of the word is a delimiter, remove the delimiter and to capitalize all letter of the word. | XML + HTTP + Request |
4 | concatenate (when two or more acronyms are successive, to use delimiter between them) | XML_HTTPRequest |