Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
The problem with C# in particular is historical. Those of us who remember the earliest days remember the internal coding style from MS which had lowerCamelCase for private members. Unfortunately, that had been scrubbed from memory/the internet, so most places adopt the most highly visible style guide, which is from google.
https://google.github.io/styleguide... -
In C++ leading underscores are reserved for standard libraries. Which means for most people don't use them.
-
dart is great with this. if a variable starts with _ it's private. no private keyword, it's style and functionality.
-
@calmyourtities Name-based semantics are a plague to language design. It makes refactoring a nightmare. We learned this with Go I believe it was.
-
On that note, why is it so common to name member variables in C++ with a leading ‘m’
That's ugly as hell -
@LotsOfCaffeine It's leftover from the ollldd days. Usually when you see such code, it's either written by someone who's been writing C/C++ for ages, or someone brand new who is parroting someone who's been writing C/C++ for ages.
-
@junon I'm pretty sure it's part of the current Google C++ style guide....
And at my work place it's also common practice -
@LotsOfCaffeine That doesn't surprise me. However most open source C/C++ from independent developers that I've personally come across avoids the m_ prefix. It just means "member" and I suppose it helps readability if you're not using `this->` everywhere, but even then, I've never personally used it.
-
iiii90854y@LotsOfCaffeine at some point in time there were no smart and powerful IDEs which could help you with types and other stuff so you've had to insert metadata in the names.
-
@iiii Don't think it has much to do with IDEs as most C/C++ developers I know still use "dumb" editors. It's just more about being able to read the code without having to check multiple places.
Now that globals/statics are discouraged, it's safe to assume more or less that a symbol not declared in the current method's scope is a property. -
In Objective-C, a leading underscore also means "Internal. Don't touch this!"
Hungarian notation has been purged from modern language style for good reasons.
Like OP said, don't use prefixes just for "style" if there is language support to express what you want to show with the prefix.
If your language supports private member variables
And it's not part of the language style guide
DONT START PRIVATE MEMBERS WITH AN UNDERSCORE.
Shit is ugly as fuck.
rant