$userName = getUserNameById( 123 );$user_name = get_username_by_id( 123 );
A few days ago was turned out of the Facebook page of the source code, almost with the underline method, WordPress is also underlined, I write PHP also like to use the underline, but sometimes hump "show professional".
While writing JavaScript, I like hump.
What kind of naming method do we all like to use?
Link: Facebook PHP Source Code from August 2007
Reply content:
$userName = getUserNameById( 123 );$user_name = get_username_by_id( 123 );
A few days ago was turned out of the Facebook page of the source code, almost with the underline method, WordPress is also underlined, I write PHP also like to use the underline, but sometimes hump "show professional".
While writing JavaScript, I like hump.
What kind of naming method do we all like to use?
Link: Facebook PHP Source Code from August 2007
Java/js, such as the use of Camel Hump, database library name, table name, field, and Web connection is used to connect with underline, CSS class, command line parameters used to connect with the cross bar.
PHP in the use of classes, objects used to use the hump name, in the global variables and functions are used to underline, but if I use the tool, the framework adopted one of the naming method, I will try to maintain consistent with him, or in a local consistency (such as a function, a large paragraph clearly distinguish between the other parts of the code).
In particular, I like to use abbreviations and alignments (not just indentation alignment, equals, colons, commas, even endings, or rendering patterns), which many people disagree with, but that's what I like.
It is recommended to follow PSR-1:
Https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md
It's very detailed, and now some of the popular libraries are being used.
驼峰“显专业”
It seems that you are not confident.
Most of the time the project itself will have normative requirements, personal habits underline (the first half is the focus)
- The hump is less readable than underlined and is especially noticeable when the variable name has a full capitalization abbreviation.
- With the hump, but also to solve the problem with which, for example
testHttpServer
TestHttpServer
testHTTPServer
TestHTTPServer
, their own easy to write inconsistent, teamwork to increase the burden of memory.
- A good IDE can help, but a good IDE can also auto-complete, then the underline does not increase the burden of the finger, and the only advantage of the hump is slightly easier than the underline to play.
Python's life style:
Http://zh-google-styleguide.readthedocs.org/en/latest/google-python-styleguide/python_style_rules/#id14
Some specific name-life methods:
module_name, package_name, ClassName, method_name, ExceptionName, function_name, GLOBAL_VAR_NAME, instance_var_name, function_parameter_name, local_var_name.
I personally also like, but their English is poor, many times know that meaning, the use of Google translation, estimated that the source will come out a lot of jokes.
I do not like to use so many underscores, if it is a good mood, the use of "hump", the mood is not even the size of the letter
All kinds of ways have, was accustomed to getName
this hump, but only with hump words, sometimes will appear not enough, such as a very long variable name arrayData_or_mapData
, a few different meanings when using other symbols such as underline to split may be more obvious, but also will style is not unified, but still practical good.
I'm used to using the initials like an underscore_getSystemDate
Different code, different products in different code style, Java with Eclipse hints named, C + + with Hungarian name, Linux kernel with Linux for the name of
PHP is good enough.
You see C + +, how many libraries are named after the standard library. Like MFC, QT, FLTK and so on are not.