There are two main approaches to dealing with variable names consisting of multiple words.
One approach – the right one – we will call K&R style. It was widely popularized by its use in the extremely influential book The C Programming Language by Brian Kernighan and Dennis Ritchie (K&R) in the 70s and 80s.
K&R style looks like this:
i_am_a_variable = 3.14 left_margin = 42Words are not capitalized and are separated by underscores.
The alternative convention for multi-word variable names is called camelCase or CamelCase. This style is used in such "words" as PowerPoint, FedEx, and iPhone. In camelCase the first letter is not capitalized, but the initial letters of subsequent words are:
iAmAVariable = 3.14 leftMargin = 42In CamelCase all initial letters are capitalized:
IAmAVariable = 3.14 LeftMargin = 42
You should use K&R style because: