When naming variables, functions, classes, etc, what naming conventions do you use? PascalCase, camelCase, Snake_Case, or other? Do you keep it consistent across all value types or do you mix it up for different types?
I prefer to use the alllowercasenounderscores case for all of my variable and function names (does anyone know what this case is actually called?) When I am naming objects I usually use PascalCase but I’m sometimes inconsistent.
edit: also I think you should move this to the discussion category.
Had no idea I could actually post there. I’ll do that.
edit: Yeah, says I can’t move it.
I’d recommend some kind of spacing or differential characterizing to improve code readability, because if I were trying to read code with names like alllowercasenounderscores i’d opt out
I use a mixture of all four*
PascalCase: Arguments, Modules, Objects, Classes
camelCase: Functions
snake_case: Variables/Data Types
UPPER_CASE: Constants
but these days I just use snake_case and camelCase.
https://roblox.github.io/lua-style-guide/
I loosely follow this as best as I can nowadays.
That aside: this kind of thread has been posted before, so you probably shouldn’t have posted it since it’s in essence a duplicate.
Here are some threads I was able to dig up by searching lua-style-guide, since there's usually someone who posts it on any thread about naming conventions.
Normally my variable names are only 1 or 2 words so it doesn’t cause too many problems.
Also some other formatting things I like to do:
I always use game.Workspace
and never use workspace
or game:GetService("Workspace")
I never ever use camelCase.
I always put spaces after commas, for example Vector3.new(12, 3, 43)
not Vector3.new(12,3,43)
I never rename services because it’s bad practice.
Personally, I use camelCase for most non-instance variables and all instances’ variables (often they’re named in Pascal, but the variable names will be camel). I use SCREAMING_SNAKE_CASE for stuff that’s going to be configured by non-programmers or just generally configurable “constant” values. However, if you’re new enough that you’re not really “set in your ways,” so to speak, I recommend following the style guide that colbert posted.
Although that’s what I do, it doesn’t really matter much, as long as you’re consistent throughout your script and it’s readable. Just please don’t use nocaps* or sPOngEbObCasE.
* I’m not entirely sure on any “official”/popular name for no capitalization or separation.
Also, this is really nitpick-y, but this isn’t technically snake_case. A “true” snake_case would be all lowercase. The case you used is called Darwin_Case.