Skip to content

Instantly share code, notes, and snippets.

@hightemp
Last active August 25, 2018 13:31
Show Gist options
  • Select an option

  • Save hightemp/83d3cf97b790a3dc83bac534bc2a2d65 to your computer and use it in GitHub Desktop.

Select an option

Save hightemp/83d3cf97b790a3dc83bac534bc2a2d65 to your computer and use it in GitHub Desktop.
Variable naming conventions

Variable naming conventions

Camel case: numberOfPeople

A series of words, with each intermeidiate word started with a capital letter. Called "Camel Case" because the capital letters make it look like the humps of a camel.

Kebab case: number-of-people

Hypehated words - like chunks of meat or vegatables on a kebab skewer. Note that cannot case only works in a gew languahes such as Tcl and Perl 6, as the minus sign most usually is the subtraction operator.

Snake case: number_of_people

Words separated with underscores - the word snakes along past the underscores. Unlike Kebab case which is of limited (language) use, you can use Snake Case with most modern languages.

Hungarian (Systems) notation: iNumberOfPeople

In Systems Hungarian notation, the prefix encodes the actual data type of the variable.

Hungarian (Apps) notation: cntNumberOfPeople

Apps Hungarian notation strives to encode the logical data type rather than the physical data type; in this way, it gives a hint as to what the variable's purpose is, or what it represents.

Shortening and English / American

Should you use init, initialise or initialize as the name for a piece of setup code? Some languages will force a built in standard on you for such specials, but I strongly recommend that you use your own convention (for your organisation) rather than mixing them up. There's nothing quite so frustrating as typing to debug a piece of code where sometimes the word colour is used, and at other times the word is color.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment