What Is Snake Case

What is snake case?

Snake case is a writing style where all letters are lowercase and words are separated by underscores. It is often used in programming languages as a way to create more readable variable and function names.

The term “snake case” comes from the fact that it looks like a snake when written out. For example the variable name “snake_case” would look like this:

snake_case

Some people also refer to snake case as underscore style or low dash.

Why use snake case?

There are a few reasons why you might choose to use snake case in your code. First it can make your code more readable especially if you use long names. Second it can make it easier to search for variables and functions since all the letters will be lowercase.

Finally some programming languages require snake case for certain naming conventions. For example in PHP all class names must be written in snake case.

How to write in snake case

Writing in snake case is fairly simple. Just make sure all your letters are lowercase and that you separate words with underscores.

Here are a few examples:

variable_name

function_name

my_class

$my_variable

my_function()

As you can see snake case can be used for both variables and functions. Just make sure you are consistent with your naming conventions.

When NOT to use snake case

There are a few cases where you might not want to use snake case. First if you are writing code in a language that doesn’t support underscores you will need to use some other method of separating words. Second if you are writing code for a project with specific naming conventions you will need to follow those conventions.

See also  What Does A Snake Tattoo Symbolize

Finally if you are writing code that will be read by humans you might want to avoid snake case since it can be difficult to read. In these cases you might want to use camel case or some other form of readable code.

Conclusion

Snake case is a simple but effective way to write more readable code. It is often used in programming languages and can make it easier to search and understand your code. Just be sure to follow the conventions of the language you are using and the project you are working on.

What is the name for the programming practice of using lowercase letters numbers and underscores in variable names?

Answer: Snake case.

Leave a Comment