Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

The naming convention for a term like doSomething is camel case.

What would the naming convention of do-something be called?

share|improve this question
15  
"Do not do this-casing." Although I wonder what language such a convention would even be supported? I'd think most languages would read that as do minus something. –  user414076 Aug 29 '11 at 17:24
14  
fail-casing ... –  IAbstract Aug 29 '11 at 17:25
24  
Minus infinity to you all!!! Never used Lisp, I'm guessing? –  Keith Layne Aug 29 '11 at 17:28
12  
like-this-casing is very common in LISP/Scheme variants. –  hammar Aug 29 '11 at 17:30
5  
It's the only naming convention that doesn't require a chorded keystroke, which makes my hands happy. You can't get away with it in most languages (LISPs being the notable exception), but I always use it as my file naming convention. –  Mud Aug 29 '11 at 21:44
show 14 more comments

6 Answers

up vote 16 down vote accepted

Delimiter-Separated which could also use the underscore (Delimiter_Separated).

...A common recommendation is "Use meaningful identifiers." A single word may not be as meaningful, or specific, as multiple words. Consequently, some naming conventions specify rules for the treatment of "compound" identifiers containing more than one word.

As most programming languages do not allow whitespace in identifiers, a method of delimiting each word is needed (to make it easier for subsequent readers to interpret which characters belong to which word).

Delimiter-separated words

One approach is to delimit separate words with a nonalphanumeric character. The two characters commonly used for this purpose are the hyphen ("-") and the underscore ("_"); e.g., the two-word name "two words" would be represented as "two-words" or "two_words". The hyphen is used by nearly all programmers writing COBOL, Forth, and Lisp; it is also common for selector names in Cascading Style Sheets. Most other languages (e.g., languages in the C and Pascal families) reserve the hyphen for use as the subtraction infix operator, so it is not available for use in identifiers and underscores are therefore used instead...

share|improve this answer
12  
Yeah, but this is too generic. Has anyone ever referred to camel case as "letter-case separated"? Plus, if anyone starts to learn Lisp because of my answer, we all win. –  Keith Layne Aug 29 '11 at 17:49
add comment

I call it lisp-case for lack of a better term, and for a lack of seeing it used much (if ever) in other language families.

share|improve this answer
1  
Here is a reference for you. –  Scott Whitlock Aug 29 '11 at 17:31
9  
For all the haters out there...Lisp is older than the alphabet. Lower case had not been invented yet. As such case did not matter and therefore all your fancy naming conventions were useless, as everything got squashed to all caps. The dashes (which a Lisp interpreter would never confuse with application of minus) were the best way to make functions, etc. readable. –  Keith Layne Aug 29 '11 at 18:05
1  
They are not haters, just that a few of us (lucky ones?) have been around longer than .NET and Java 1.6. History is not a fav topic in Comp Sci courses. –  mattnz Aug 29 '11 at 20:58
1  
@matt True, but Scheme and Lisp should still be, at least in some places. My first ever CS course was taught in Scheme and it blew my mind and changed my major. I wonder about the state of today's CS education...used to be everyone used SICP. –  Keith Layne Aug 29 '11 at 21:24
2  
While not technically an actual language - it's one of the common conventions that CSS designers use for naming element ids and classes. Also, HTTP header names use hyphen separators. So, true that Lisp likely did it first - but it's not a convention unique to Lisp. –  HorusKol Aug 30 '11 at 2:58
show 1 more comment

According to Wikipedia, this is known as spinal-case (and the upper case version is called Train-Case):

spinal-case or Train-Case: similar to snake_case, but spaces are replaced by dashes, instead of underscores.

share|improve this answer
1  
+1 For a reference (even if it is Wikipedia. Shows that at least one other person uses these terms) –  KChaloux Aug 6 '13 at 16:47
add comment

I like "caravan case", because it looks like tokens chained together in a caravan. You can even picture a caravan of camels if you like.

share|improve this answer
1  
Is this something you just now made up, or have you actually seen or heard someone use this term? –  Jay Elston Sep 2 '11 at 5:12
    
I made it up just now. I don't think I've ever seen it used anywhere. –  boshvark Sep 4 '11 at 18:39
add comment

Dasherization, usually used for URLs or other human readable cases.

share|improve this answer
add comment

The only time I see naming like that is for SEO purposes, so maybe SEO-case? In any event, it's not a good naming convention to use.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.