Thursday, February 27, 2020

Naming style cases strings - camel,snake,kebab,pascal cases tutorials with examples

Case name styles in programming

String is a group of characters which contains word(s). Sentence is group of strings or words
In programming languages, there are different types strings cases styles available 

There are various case styles for combing words to declare a variables or functions or URL in programming languages, This will be used as  conventional notations only.
All programming languages not follow all cases.

For example, Camel Cases in java are used for declaring variable names,kebab case are used in lisp language for define variable names.

We are going to discuss about different case strings.

Following are different cases name styles notations available in various programming language.

Case type Example alternative names
camel case firstName camelCap
snake case first_name underscore case
Kebab case first-name hyphen , dash or caterpillar or lisp or css case
Flat case firstname simple case
Flat case firstname simple case
cobol case FULL_NAME FULL CAPS CASE or Train case

Camel case conventional 

camel case also abbreviated as camelCase or camel caps 
  • first character of each word is upper case.
  • In programming languages, variables declared with camel case where first character of each word is Uppercase except first word. 
  • That means each string starts with lower case.
  • came cases can be  FullName or firstName
  • Important points
  • spaces and punctuation in strings not accepted
  • These are conventional notations only not have syntax effects.
  • used in declaring variables or member variables for a objects in object programming languages like java
  • underscore not accepted
valid camel cases examples are ZipCode, lastName.
Invalid examples are zip code, full_name, phone-number.

snake case strings

These are compound words, each word is separated by underscore symbols
hello_world is a snake case string example.

Important points about snake case sentences
  • Each word is separated by underscore
  • spaces and punctuation are not allowed
  • these are used in declaring variables  and method names in some programming languages
  • starting letter of each word is either lower or uppercase.
  • Convention notation is to use starting letter as lower case.
valid snake case examples are first_name and last_name,Full_name
invalid snake case examples are "first name", "employee,salary"

Kebab or Hypen case

Also called hyphen case or dash case, which is used to join the string  of words with hyphen symbols, where all the words are in lower case.

Important points
  • each word in component sentence are separated by hyphen (-) symbols
  • All the words are in lower case only
  • These will be used in declaring variables in Lisp programming language and also defining URLs with this conventional notation in SEO.
valid names are naming-style-case-example
Invalid names are first_name

Example case styles examples in JavaScript

Related article


EmoticonEmoticon