Snake case (or snake_case) is the practice of writing compound words or phrases in which the elements are separated with one underscore character (_) and no spaces, with each element's initial letter usually lowercased within the compound and the first letter either upper- or lowercase--as in "foo_bar" and "Hello_world". It is commonly used in computer code for variable names, and function names, and sometimes computer filenames. At least one study found that readers can recognize snake case values more quickly than camelCase.
Video Snake case
History
The use of underscores as word separators in identifiers in programming languages is old, dating to the late 1960s. It is particularly associated with C, being found in The C Programming Language (1978), and contrasted with Pascal case (a type of camel case). However, the convention traditionally had no specific name: the Python style guide refers to it simply as "lower_case_with_underscores".
Within Usenet the name "snake_case" was first seen in the Ruby community in 2004, used by Gavin Kistner, writing:
"BTW...what *do* you call that naming style? snake_case? That's what I'll call it until someone corrects me."
However, a former Intel engineer, Jack Dahlgren, has stated on Quora that he was using the term internally at Intel (and perhaps in dialogue with Microsoft engineers) in 2002. It is possible that the same term has developed independently in more than one community.
As of 2015 names for other delimiter-separated naming conventions for multiple-word identifiers have not been standardized, although some terms have increasing levels of usage, such as lisp-case, kebab-case, SCREAMING_SNAKE_CASE, etc.
Maps Snake case
Examples of languages that use snake case as convention
- OCaml, for value, type, and module names
- ABAP
- C, for the standard library
- C++, for the standard library and Boost
- Erlang, for function names
- Perl, for lexical variables and subroutines.
- PHP, for functions, but not class methods. Older conventions were often to use snake case for every type of identifier, except classes and namespaces.
- Python, for variable names, function names, method names, and module or package (i.e. file) names
- Ruby, for variable and method names
- Rust, for variable and function names, among other items
- Elixir, for atom, variable, and function names
- Eiffel, for class and feature names
See also
- Camel case, more common in Java
- Kebab case, more common in LISP
- Naming convention (programming)
References
External links
- Snake case converter
Source of the article : Wikipedia