Compound words by One Word
Since the Camel case and snake_case are for compound words, maybe it was unexpected that compound words made from one word. Rules of Intact Case can be applied even in the case that compound words made from one word.
camelCase ⇒ snake_case
|2||add a delimiter to after each acronym||HTML_|
|3||all words to lower case||html_|
|4||concatenate with between delimiter||html_|
snake_case ⇒ camelCase
|1||tokenize by delimiter||html_|
|2||capitalize each word except first||Html_|
|3||If last letter of the word is a delimiter, remove the delimiter and to capitalize all letter of the word.||HTML|
Camel Case Which First Word is an Acronym
If the first element of the compound words is the acronym, rules of camelCase makes it as StudlyCaps. Because first letter of the compound words made is uppercase.
- PHP + Unit = PHPUnit
- IO + Exception = IOException
The compound words can be applied as class name in Java. However, there are a problem when it is applied as method name. If it is converted to lowercase only the first letter of the compound words, the word is splitted at between first and second letters. Because the succession of lowercase and uppercase is recognized as separated token.
- PHPUnit ⇒ pHPUnit ⇒ p + HP + Unit
- IOException ⇒ iOException ⇒ i + O + Exception
In Intact Case, for keeping all token of compound words that contains acronym, convert to lowercase first element of compound words as follows.
StudlyCaps ⇒ camelCase
|1||tokenize||PHP + Unit|
|2||convert to snake_case first word||php_ + Unit|
camelCase ⇒ StudlyCaps
|1||tokenize||php_ + Unit|
|2||convert to StudlyCaps first word||PHP + Unit|
This rule can be applied even if the first word is not an acronym. It can be deemed that the conversion rules of camelCase and StudlyCaps is generalized.
Reversibility and Readability
When compound words contains acronym, underscore is successive two in snake_case. It makes us to think whether some people feel uncomfortable to successive two underscore. The goal of Intace Case is that natural interconversion of camelCase and snake_case. We think that keeping token and redundancy of delimiters is in the trade-off.
In other words, Intace Case is the rule for projecting the acronym to snake_case. The reversibility and readability of Intact Case would be useful for something.
|Reversibility||Natural mutual conversion of camelCase and snake_case|
|Readability||To keep token of acronym in snake_case|