Pascal Case

Updated Mar 7th, 2020 / 2 min read

About this...

Pascal Case is a naming convention that promotes naming indentifiers using all upper-case words.




Pascal case (or should I say PascalCase) is one of three primary capitalization conventions (underscore, Pascal, and camel) used in programming languages.

Pascal case dictates that each word in an indentifier be capitalized with no separators (like underscores) in between them.

Not pascal case

type user = {   id: string; 
  name: string
}

interface serializable {  toJSON (): string;
}

class user_model implements serializable {  ...
}

const shouldlistenToJohnMaus = likesWeirdmusic() && isGenerallyAHappyPerson();

Pascal case

type User = {   id: string; 
  name: string
}

interface Serializable {  toJSON (): string;
}

class UserModel implements Serializable {  ...
}

const ShouldListenToJohnMaus = LikesWeirdMusic() && IsGenerallyAHappyPerson();

The role of Pascal case in TypeScript & JavaScript

In TypeScript & JavaScript, the Pascal case convention is usually used to signify that an identifier is a class, type, or interface.

We would normally use Pascal case for things like this:

// This is conventional!
type User = { 
  id: string; 
  name: string
}

// Also conventional usage!
interface Serializable {
  
  // But notice that the attributes are NOT Pascal case.
  toJSON (): string;
}

// Pascal case on classes are conventional.
class UserModel implements Serializable {
  ...
}

But not for variables or functions:

// It's not conventional to use Pascal case for variables or functions in TypeScript and JavaScript
const ShouldListenToJohnMaus = LikesWeirdMusic() && IsGenerallyAHappyPerson();

Pascal case in other languages

  • In C#, Pascal case is used for most things. It's a common convention to name variables, function, classes, and interfaces using Pascal case.

See also

0 Comments

Be the first to leave a comment

Submit