[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Naming variables
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 18
Thread images: 2
What the fuck is pic related? Are there people who actually start the name of things with an underscore? How the fuck do you get taught such an inefficient and useless convention instead of camelCasing?
>>
Prefixing variables is basically what you do if you don't want anyone to use them, but still want them in the global scope.... Or if you're a php dev, may God have mercy on you.
>>
Prefixing fields with an underscore is a standard u mong
>>
Confirmed for never having worked with Python.
Underscore means protected variables because Python can't into true scoping / namespaces / whatever.

People use underscope as a workaround for this. I find it _hilarious.
>>
>>51237289
It's the denote between a property and a regular variable or parameter that might have the same name.
>>
If you're on a team, chances are you'll have a style guide.
>>
>>51237565
that's not python and it didn't create the convention
>>
>>51237601
You're right: I did.
I invented the underscore convention.
>>
>>51237617

You are objectively a bad person

Underscores are a legitimate inefficiency to use because it requires you to hold down shift and press a key that is typically outside the standard range for your hands when using the keyboard. Just because python is a shit language and doesn't have things that should be common sense doesn't mean you can carry over this retarded concept to functionally good languages
>>
>>51237781
Well, you can kiss my protected ass.
>>
File: icametolaughatyou.jpg (32 KB, 640x480) Image search: [Google]
icametolaughatyou.jpg
32 KB, 640x480
>>51237781
>standard range for your hands
get a better keyboard layout, pleb. underscores are common in function names, too. you seemed to ignore that.
>>
>>51238174

Why the fuck don't you use camelCasing? Underscores should only be used for constants typed in all caps to signify a space between words
>>
>>51237601
you're wrong, it is part of the python grammar

putting a underscore before the variable will invoke python name mangling, making the field much more difficult to access (typically used for private attributes)
>>
>>51238593
how do you camelCase variable names like age. do you use "age" or "Age"?
>>
>>51240221

just 'age'. The name of a class starts with a capital, but variables and methods start with a lower case letter. All subsequent words start with a capital, however the first word is always lowercase in a variable name
>>
Literally who cares, it's just a convention.

If you're working on something personal, do whatever the fuck you want.
If you're working on a team use whatever you're told to use.
>>
>>51237781
>Implying you use a QWERTY keyboard
>>
>>51240221
C# style is to have properties (public member variables) PascalCase, In fact, many things use PascalCase. Also, camelCase or even _underscoreCamelCase are for private member variables.
Thread replies: 18
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.