DEV Community


Discussion on: snake_case, camelCase, or dash-case?

ale_jacques profile image
Alexandre Jacques

It varies strongly from language to language.

Java has a de facto styleguide that says variables should be camelCased and classes should be CamelCaps (and other "rules" and conventions - POJO conventions comes to mind).

Python has PEP8 that also has their saying: classes should be CamelCaps and variables, snake_case (both, preferably - exceptions apply).

PEP8 is a interesting reading.

@yujiri8 mentioned JSON has a standard and, AFAIK, there isn't an official one. The docs says that properties names should contain only 'a'..'z', 'A'..'Z' and '_'. There's also no indication on ECMA of a standard.

Kebab case is, IMHO, confusing as it would be mistaken for a minus sign (and probably incompatible in some languages).

My take here is: follow the language convention. It's easier on the eyes of people that has more time/experience on the language and less work for the linter (if you use one - PS: you should).

patarapolw profile image
Pacharapol Withayasakpunt

In some Python libraries, like PyQt, uses CamelCase (PascalCase).