How best to name variables and functions?

Hi. Recently wondered how to call variables and functions. I understand that this is probably very subjective, but I want to hear your opinions. We are not talking about notation. It is also clear that the variable name should accurately reflect its contents. I want to know about the sequence of words, time, length, names, etc. for Example, what would you name the "total time user store" (in functions of the time counters of preserving users), total_time, time_total, save_time_users, etc.? The first word should most reflect the contents of the variable (time_total) or better to call as we speak (total_time)? Does it make sense to call the variable parts of speech, i.e. palgaerinevustele? get_groups_user or get_user_groups?
I think the meaning of the question clear. I want to write uniform and understandable code. Share your vision, can be examples.
August 19th 19 at 23:25
5 answers
August 19th 19 at 23:27
PEP8 here written recommendation about them and about the variables, about classes, about the positioning, about the number of characters in the string, about the indentation..
The question is not about margins, not the number of characters in the string are not about the positioning, not about notation, which describes pep8, and properly naming variables to make it easy to understand the code. - malachi_Vandervort7 commented on August 19th 19 at 23:30
: indents and the number of characters in the string strangely enough also affect readability (understanding) the code. - Rogers.Hyatt commented on August 19th 19 at 23:33
: Of course, and I know it. What I'm asking is that I don't know) - malachi_Vandervort7 commented on August 19th 19 at 23:36
: Read carefully PEP8 - it's not just about indents and spaces, there is a section "naming conventions" - as the answer to your question. "How many times asserted the world..." - RTFM! - Lolita_Pauc commented on August 19th 19 at 23:39
: Well I have read 10 times PEP8, there is about style, notation, etc. It's obvious. My question is. The order of words in a name, part of speech, relevant articles, etc. Stop poking me PEP, I already know it. Or I read something wrong with PEP, I do not understand. - malachi_Vandervort7 commented on August 19th 19 at 23:42
August 19th 19 at 23:29
Thank you - malachi_Vandervort7 commented on August 19th 19 at 23:32
August 19th 19 at 23:31
The most important rule - that in this context, it was immediately clear what the variable means. The closer to English, the better (the order of words to retain). There are only a few basic rules:
- the main word in the title is a noun or an adjective
- Boolean can be prefixed with is_... (but not isnot_...)
- articles do not use

No need to duplicate the meaning of which is clear from the context. If we have, say, a method parse_html(), there is html_nodes you can simply write nodes.
Thanks for the opinion - malachi_Vandervort7 commented on August 19th 19 at 23:34
August 19th 19 at 23:33
If you work in a team is to sit down and write the list of words comprise names, as well as a list of pairs such as Add/Remove, Open/Close, Program/Clear, Create/Destroy to some is to add meaning.
For example, the Init method produces the initialization of the content of the object, in fact an analogue designer, and it can't be nothing else except the first reference to this object, and let the Reset puts the object in the same initial state but from any state.
Size is the size in bytes, words or something else what they have.
Len or Length the length in elementno

Code will be read and understood much easier
August 19th 19 at 23:35
Thanks, will read - malachi_Vandervort7 commented on August 19th 19 at 23:38

Find more questions by tags ProgrammingPython