CamelCase Notation- Naming Convention for Programming Languages

CamelCase is the practice of writing compound words or phrases in which the words are joined without spaces and are capitalized within the compound like BreakFast, myName etc. CamelCase is so named because each word in the identifier is put together without spaces, but with the first letter of each word captilised, looking like humps of a camel.

There are two varieties in CamelCase:

In Java variables, references, method names are declared in lowerCamelCase.

//Variable declared using lowerCamelCase
int animalCount;

//Method defined using UpperCamelCase
public abstract int getAnimalCount();

UpperCamleCase is also called as Pascal Notation. The only difference between the LowerCamelCase and UpperCamelCase (Pascal Notation) is that the first letter of the compound word is capitalized in case of UpperCamelCase while it is not in case of lowerCamelCase. In Java class names are declared in UpperCamelCase notation.

Observe the UpperCamelCase notation used 
for declaring the class name
class AnimalTest 
  String name;
  public AnimalTest(String name)

Read more on Java Programming Style Guide here.

For more information on the CamelCase notation here.

Apart from camelCase we have:
– PascalCase – multiple words are capitalized (first letter being capital). C# uses this convention and in Java we use this for class or enum naming.
– kebab-case – multiple words are in the small case and separated by dash (-). Lisp language uses this convention. We also use this in naming the attributes in HTML. Like animal-name.
– Snake_case – multiple words separated by underscores (_). Like animal_name


3 replies »

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s