Case Styles

Naming Convention:

Shivani Nalawade
3 min readMay 15, 2020

In computer programming, a naming convention is a set of rules for choosing the character sequence to be used for identifiers which denote variables, types, functions, and other entities in source code and documentation.

Reasons for using a naming convention🤔:

  1. To reduce the effort needed to read and understand source code.
  2. Significant issues other than syntax and style preferences.
  3. To focus on more important issues than arguing over syntax and naming standards.

Removing spaces between words

  • In programming, we remove the spaces between words because programs of different sorts reserve the space (‘ ’) character for special purposes. Because the space character is reserved, we cannot use it to represent a concept that we express in our human language with multiple words.

As an example, the concept of enter number count is not referenced in our code as enter number count often. We do not do the following:

enter number count=5

A typical language parse would treat each word as a separate concept. enter, number, and count would each be treated as separate things. So, we do something like the following:

enterNumberCount=5

Camel Case (camelCase) :

In camelCase each word or abbreviation in the middle of the phrase begins with a capital letter, with no intervening spaces or punctuation. Common examples include “iPhone” and “eBay”.

  • Camel case combines words by capitalizing all words following the first word and removing the space, as follows:

Raw: enter number count

Camel Case: enterNumberCount

This is a very popular way to combine words to form a single concept. It is often used as a convention in variable declaration in many languages.

for example;

function Hospital(){

patientName : string =””;

patientId : number =0

}

In above example we follow camelCase (Naming Convention).We decalre one function name as Hospital() inside the function we declare two variables patientName and patientId. Both variables declare in camelCase. patientName word is made by two words (patient & name) so we write a letter of first word i.e; patient( first alphabet) in small letter and word i.e;Name( first alphabet) in capital letter.

Pascal Case (Pascal Case) :

Pascal casing is similar to camel casing except that the first letter also starts with a capital letter (SomeClass instead of someClass).Software developers often use PascalCase when writing source code to name functions, classes and other objects.

for example: SomeVar, SomeClass, SomePackage.xyz

  • Both PascalCase and CamelCase help developers distinguish words within names. For example, “LongFunctionName” is more readable than “longfunctionname.”
  • Some time we declare variable of function which are made by combination of words like: “hospitalname”, using PascalCase we can declare such type of word such as follows…

class Hospital{

PatientName: string=””;

}

Underscore( _ ) :

This case all letter are in small letter and word start with underscore( _ ).

  • for example; _supplier , _student , _customer and so on …Most of the case we can use this case for declaring ‘private variables’. It’s simply a naming convention that reminds the developer that the variable/property/method is either private or protected, and cannot be accessed from outside of the class.

for example;

class Student{

_name : String = “”;

_id : number = 0;

}

In above example we create one class name as Student and inside the class (Student) we declare two variables _name and _id using Underscore.

I hope this guide has been helpful for you. If you would like to explore more concepts on Angular, check out this video 👇:

--

--

No responses yet