Is there any nomenclature for variables defined by underline/underscore?

Asked

Viewed 1,515 times

6

I know that there are some rules and conventions for the nomenclature of variables in programming, such as Camelcase, Pascalcase, etc....

What is the term used for a compound name variable (words separated by "_")?

Example: nome_da_variavel

3 answers

6


I know this separation by the name of Snake Case.

According to the Wikipedia reference, the name Snake case was created by the Ruby community.

Examples

In some languages, it is common to see snake_case used for some functions or variables, such as Python. It seems that the people who develop in this language have a preference to define functions or variables with this pattern.

Example:

 def minha_funcao(**args):
     pass

 resultado = minha_funcao(1)

Commonly, in Python, we see the use of Snake case combined with lowercase. Maybe that’s why according to Wikipedia, the name used by Python’s Style Guide was lower_case_with_underscores.

In PHP we also see this pattern being applied to functions and variables, and the small difference is that in cases of variables considered Super Global language, is written in uppercase.

Behold:

 $usuario_id = obter_id_usuario($_GET)

References:

https://en.wikipedia.org/wiki/Snake_case

6

Yes, this pattern is commonly called Snake case (snake_case, in this case :p).

There is no official name for this pattern, Snake case was the name that the Ruby community gave him (that’s right, it wasn’t the Python people).

The python style guide calls this pattern of lower_case_with_underscores.

  • 3

    Gee, I was sorry to hear that the Python guys didn’t adhere to possible "Snake" puns with "python". Apparently, they must be very serious kkkkkk

  • @Wallacemaxters import antigravity

6

Snakecase or Underscorecase are the terms used for the case you use "_".

Snake case is very old and comes from the beginning of C, but received this name recently.

Here has a good understanding of all the conventions that I believe are useful in your study.

Source

  • 1

    I like the convention list! + 1 ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.