'Why do you use C-Style Naming Conventions?'

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

I personally like different cases for different things in a language. For example, classes being in PascalCase and variables being in camelCase makes it very easy to understand the code, you can immediatly see if it's static or not.

nilstrieb
Автор

I think there's a simple solution to the "manager nitpicking" problem you didn't mention: just use automated tools and git hooks to check that the style is enforced before you commit. That way, you get the feedback much earlier and can fix it without having to go back and forth in a drawn out review. Ideally, you'd have these tools integrated in your editor too, for immediate feedback. Most style rules are easy to automate in this way. There may still be subtle ones that require human judgement, but then we're getting into the territory of what code reviews are actually for.

iwikal
Автор

That's very interesting! Thanks for sharing it!

UnidayStudio
Автор

OH my god, finally someone said it. :)
Nice upload! hahahah!
The "manager" bit. Dead on.

Luxis
Автор

Need to write a function.
"Fuck"
John: heh

petermaltzoff
Автор

Great points! 100% agree. It's the most readable and simple and consistent.

Another one for me is that _single letter parts_ of names are no problem in snake_case. E.g:

`float negative_x_positive_y;`
or
`float x_negative_y_positive;`

is clear. But non of he PascalCase/camelCase variants are

`float NegativeXPositiveY;`
`float XNegativeYPositive;`
`float negativeXPositiveY;`
`float xNegativeYPositive;`


except if you only capitalize the single letters only but that's an exception breaking the convention already:

`float negativeXpositiveY;`

michael-nischt
Автор

More defined constants and make it a full sentence named variable so I can understand plzzz

chrislesage
Автор

I would say it's a taste thing and there is definitely nothing bad about C-style naming convention (indeed I like it as well).
Regarding manager going through the code and pointing out the wrong styling - imho style consistency in the codebase is quite important when working in a team (not saying the other things you've mentioned about how the code runs etc. are wrong though)

artemdyadichkin
Автор

Me looking at C# code: _confused pikachu face... "is that a function or a class constructor? Is that a variable?? Which way is up?"_
Color highlighting helps, of course, but I can't just read the code, I still have to decipher it to some extent.
I use PascalCase ONLY for class names and constructors (I don't code in C/C++, though). I follow python conventions, mostly. But that's only because my brain kinda likes to see constructor calls immediately distinct from normal functions, even though I find snake_case more readable.

Not mentioning PascalCase requires using shift more often, which is cumulatively more annoying to me. And I find it easier to always type shift+_ than shift+[insert letter here]. Generally speaking, I think snake_case is a more relaxed way to code.

skaruts
Автор

Makes a lot of sense. I personally adopted casey's naming convention because I have a pretty small monitor and when I use pascal case, I can fit more stuff on the screen. Also, I think the capital letters stand out among all lower case keywords and make the code a little bit more readable to me. Now that I started studying CS in college though, most people there use c-style convention, so I kind of have to adhere to that. I assume in workplaces it's similar, so maybe i'll reasses my conventions to get more used to it.

stewartzayat
Автор

>You can go through every single line of my code, it's gonna look the same.

Everything looks the same, but it's not the same. That makes the code less readable, in my opinion.

&someName

In Zig, everyone knows this is the address of a function without them needing any further context, because only functions use that casing. That's a huge benefit imo.

mr.mister
Автор

If you will ever use Win32 API it will become a mess though. MS uses style.

kvolt
Автор

I really like that style. Sadly I'm in too deep to switch.

HobokerDev
Автор

This video came to my mind now. I was just noticing that codebases that use camelCase seem to have a tendency for inconsistencies. For example, Love2D is all camelCase, but then it has functions like *keypressed* and *mousemoved.* The Nim language is camelCase as well, and the standard library has stuff like *popcount, countup* and *countdown.*
I'm gonna be noticing this stuff from now on, lol.

skaruts
Автор

classicVariable
m_publicMember
m_privateMember_
FunctionsAndMethods()
n_nameSpaceMember

ThisShitWontWor