this post was submitted on 07 Feb 2021
0 points (NaN% liked)

General Programming Discussion

7785 readers
4 users here now

A general programming discussion community.

Rules:

  1. Be civil.
  2. Please start discussions that spark conversation

Other communities

Systems

Functional Programming

Also related

founded 5 years ago
MODERATORS
 

CamelCase? snake_case? Something else? And why?

top 4 comments
sorted by: hot top controversial new old
[–] [email protected] 1 points 2 years ago

PascalCase or camelCase (note the capitalization of the first letter, that's the difference between the two) basically always.

[–] vodnik 1 points 2 years ago

I really like kebab-case, because I’m a lisp aficionado

[–] [email protected] 1 points 2 years ago

Once I was checking somebody's code against a coding style and asked him why he capitalised a certain identifier that wasn't a type. His reply was along these lines: This word is a German noun. In the German language all nouns are capitalised. It is better to have the identifier look like the real word, because it uses less cognitive resources. Your IDE can tell you about the nature of the identifier. Your name should only reflect how it is used.

I kinda liked the idea (and maybe forced him to conform to the rule, I don't remember). In the end I've come to appreciate, when you can use identifiers that really look like normal text.

eat_French_cheese(new Le_Curé_Nantais()); {Not a memory leak - the cheese is properly consumed/destroyed by fnc}

And I hate if the compiler allows to have different identifiers that only differ in case. E.g. "RailsExpr" and "railSexPR" shouldn't be allowed coexist in the same code. (Neither should indentation with tabs and indentation with space coexist in the same file).

[–] [email protected] 1 points 3 years ago

snake_case for variable names because they seem to be holding something in their underscores. camelCase for functions because verbNoun looks good. PascalCase for classes because it looks like it's a level above that needs to be instantiated before getting used.