

Here are some examples of how you would use pascal case: NumberOfDonuts = 34 So, when using pascal case, every word starts with an uppercase letter (in contrast to camel case, where the first word is in lowercase). The only difference between the two is that pascal case requires the first letter of the first word to also be capitalized. You will encounter camel case in Java, JavaScript, and TypeScript for creating variable, function, and method names. Then, the first letter of the second word, Of, is capitalized, as is the first letter of the third word, Donuts. In the example numberOfDonuts, the first word number is lowercase. Here are some examples of how you would use camel case: numberOfDonuts = 34 So, a capital letter appears at the start of the second word and at each new subsequent word that follows it. Then, you capitalize the first letter of each word that follows. When using camel case, you start by making the first word lowercase. You will encounter kebab cases mostly in URLs.Ī URL (short for Uniform Resource Locator) is a unique address for accessing a resource on the Web.

Here are some examples of how you would use kebab case: number-of-donuts = 34

The kebab case is another one of the most human-readable ways of combining multiple words into a single word. So, all words are lowercase, and each word gets separated by a dash. The difference between snake case and kebab case is that kebab case separates each word with a dash character, -, instead of an underscore. The kebab case is very similar to snake case. A constant is a data item whose value doesn't change throughout the life of a program. The capitalized version is used for declaring constants in most programming languages. Here are some examples of how you would use upper case snake case: NUMBER_OF_DONUTS = 34 There is also an all-caps version of the snake case where all letters are in the upper case - also known as the screaming snake case. You will also come across it when working with databases, as it is used for creating table and column names. You will typically encounter it the most when programming in Python and not so much when programming in Java, JavaScript, or TypeScript. Snake case is also a good choice for naming files, as it keeps names readable. Snake case is used for creating variable and method names. Here are some examples of how you would use the snake case: number_of_donuts = 34 When using snake case, all letters need to be lowercase. Snake case separates each word with an underscore character ( _). Let's see each case in more detail in the following sections.
#Computer science word vs word code#
That way, your code will remain readable, easy to understand, and maintainable for yourself and other developers you may be working with on a team. It is best practice to choose one case style and stick with it. When choosing a case style, keep in mind the best practices of the programming language you are using in your project.Īnd no matter which case you choose, remain consistent in your project.

When it comes to using case styles, there is no definite answer as to which one is the best. Specifically, there are certain naming conventions available across all programming languages, also known as: And there are a few ways available to combine them. Number, of, and donuts are treated separately from each other because of the space character in between them.įor your program to work correctly, you need to remove all the spaces and combine the words into a single string in a specific way. Most (if not all) programming languages interpret each word as a completely separate thing and a single unit. If you tried the above, you would get an error. Say you want to create a variable in your program, and the name of the variable is more than just one word.įor your program to not crash, you cannot leave spaces between the different words when creating the variable.įor example, you cannot do the following: number of donuts = 34 In programming, spaces are reserved characters. In this article, I will explain the differences between the most widely used case types in programming. Indeed, naming things when programming can be challenging when you have different naming conventions available. “There are 2 hard problems in computer science: cache invalidation, naming things, and off-by-1 errors.”
#Computer science word vs word software#
As a software engineer, you may be familiar with the following quote by Leon Bambrick:
