Saturday 26 October 2013

Underscores or dashes

Both underscores and dashes can be used to connect words in a file system. Using dashes may make the names look nicer, but there are reasons to use underscores:

  • In Python, you have to name the files with underscores in order to import it in Python.
  • Many languages have the convention to name files with underscores: Python, Ruby, C++.
For coding, only underscores can be used in a variable name, because dashes will be confused with the minus sign. In Ruby, you can't use dashes in symbols either. So to be consistent, just use underscores in programs too, even in the string keys.

For url naming, it is a different story. If you have a underscore in the url, Google will combine the two words. So bla.com/wk1_kw2.html wouldn't show up by itself for kw1 or kw2. So when you search, you have to search for kw1_wk2 to bring up that page. 

No comments :

Post a Comment