The Cusp of Helix

Intact Case [Details]

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

#ProcedureActual Example
0original StudlyCapsHTML
1tokenizeHTML
2add a delimiter to after each acronymHTML_
3all words to lower casehtml_
4concatenate with between delimiterhtml_

snake_case ⇒ camelCase

#ProcedureActual Example
0original snake_casehtml_
1tokenize by delimiterhtml_
2capitalize each word except firstHtml_
3If last letter of the word is a delimiter, remove the delimiter and to capitalize all letter of the word.HTML
4concatenateHTML

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

#ProcedureActual Example
0original StudlyCapsPHPUnit
1tokenizePHP + Unit
2convert to snake_case first wordphp_ + Unit
3concatenatephp_Unit

camelCase ⇒ StudlyCaps

#ProcedureActual Example
0original camelCasephp_Unit
1tokenizephp_ + Unit
2convert to StudlyCaps first wordPHP + Unit
3concatenatePHPUnit

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.

ReversibilityNatural mutual conversion of camelCase and snake_case
ReadabilityTo keep token of acronym in snake_case