This is a creation in
Article, where the information may have evolved or changed. The Go language also has its own naming and code organization rules. Beautiful code, layout clear, easy to read and understand, like a rigorous design of the API. Get the code, the user first see and touch is the layout, naming and the structure of the package. This article is not to set up hard rules for you, but to use practice to guide everyone to form their own rule
Welcome to follow my microblog and click to open the link
For details about this naming rule, refer to the Google C ++ programming style guide. Although the rules are dead, they can be improved according to the rules.CodeTo facilitate code sharing, which is helpful for improving the individual's coding capability.
1,General rules
The name cannot be abbreviated at will, even if it is understood by o
For details about this naming rule, refer to the Google C ++ programming style guide. Although rules are dead, rules can always improve code readability and facilitate code sharing, it is helpful for improving the individual's coding capability. 1. General naming rules do not support arbitrary abbreviations. Even abbreviations are based on what others can understand. The type and variable should use nouns,
) constant;3) constructor function.4) destructor.5) member function. contains static member functions;6) data members, including static data members.Macro Disallow_copy_and_assign after the private block. As the last part of the class.12. Writing short functionsTend to choose short, condensed functions.Long functions are sometimes appropriate, so there is no strict restriction on the length of the function.Assume that the function exceeds 40 rows. Be able to consider cutting it without affecting
Order
Public in front of private, method in front of the variable.
Public, prtected->private, each part in the following order:
Typedef and enumerations
Constant (static const data member)
constructor function
Destructors
Method that contains the static method
Data members
Friends are declared in private, disallow_copy_and_assign at the end of private.
Write short function
Functions over 40 rows should be considered
"Google C + + programming style Guide" for header file contains order
C system files.
C + + system files.
Other libraries '. h files.
Your project ' s. h files.
The preferred ordering reduces hiddendependencies. We want every header file to is compilable on its own. Theeasiest way to achieve it's to made sure that every one of them is the First.h file
in order to enhance readability and avoid implied de
hide according to logical judgmentHidewithoutmouse: Hidden when the mouse is not on the controlIdepixelborder: Decide whether to draw a border around the TabControl Panel controlShowarrows: Determines whether the arrow in the upper-right corner of the panel is displayedShowclose: Decide whether to display the Close button in the upper right corner of the panelL Display the Code editing window on the central panel Centerpanel CodeeditorYou need to generate a TabPage object first, then wrap the c
This article mainly introduces the FancySelect use guide for jQuery's flat style drop-down box beautification plug-in. For more information, see FancySelect, a small and practical jQuery drop-down box beautification plug-in. The drop-down box beautification plug-in adopts a flat design style and is one of the preferred drop-down box beautification plug-ins for fa
each substring to the list and then use the . Join Connection list after the loop ends.#Yes--------------------------Items = [''] forLast_Name, first_nameinchEmployee_list:items.append (''%(last_name, first_name)) Items.append ('') employee_table="'. Join (items)#No--------------------------Employee_table ='' forLast_Name, first_nameinchemployee_list:employee_table+=''%(last_name, first_name) employee_table+=''@11: use triple double quotes instead of triple single quotes for multiline
not be in the other header file in front of the declaration, try not to public;3. As far as possible without global functions and global variables, consider scope and namespace constraints, as far as possible to form a single compilation unit;4. Global variables in multiple threads (with static member variables) do not use class types (including STL containers) to avoid bugs caused by ambiguous behavior.The use of scopes, in addition to name pollution, readability, mainly to reduce the coupling
FancySelect user guide for jQuery flat style drop-down box beautification plug-in, jqueryfancyselect
FancySelect is a small and practical jQuery drop-down box beautification plug-in. The drop-down box beautification plug-in adopts a flat design style and is one of the preferred drop-down box beautification plug-ins for fashion developers.
Usage
HTML Structure
Fan
list is placed in the same row or indented in a few rows by four cells.Two acceptable initialization list formats:When it all fits on one line:Myclass::myclass (int var): Some_var_ (Var), Some_other_var_ (var + 1) {OrWhen it requires multiple lines, indent 4 spaces, putting the colon onThe first initializer line:Myclass::myclass (int var): Some_var_ (Var),//4 space indentSome_other_var_ (var + 1) {//lined up...DoSomething ();...}15. Namespace formattingNamespace content is not indented.Namespac
set member classes to public unless they are part of an interface
Non-members, static members, and global functions
It is recommended to use a non-member function or a static member function in a namespace instead of a global function.
Local variables
Use local variables as much as possible in the smallest domain, and initialize them at the time of declaration.
C + + supports declaring local variables anywhere in a function, but it is better to be more local, clo
following cases:1. Between methods2. Between local and first line statements in a method3, before multiple lines or single-line comments4. Improve the readability of code between logical code blocks in a methodSpaces should be used in the following cases:1. Keywords followed by parentheses should be separated by a space2. A space should be left after the comma in the parameter list3. All except the points of the two-dollar operator, the operation should be separated by a space. MonocularOperato
action to create an object instanceGood wording.function MyObject () {Code}Bad syntax: Start with a lowercase letterfunction MyObject () {Code}Bad wording: using underscoresfunction My_object () {Code}Bad writing: start with a verbfunction Getmyobject () {Code}Constants (variables that do not change values) should be named for all uppercase letters, separated by a single slide between different wordsGood wording.var total_count = 10;An object's properties are the same as a variable's naming con
variable = = "undefined") {Do something;}Bad writing: The use of undefined direct volumeif (variable = = undefined) {Do something;}Four: operator spacingA space must be used before and after the ternary operator to keep the expression neat.Operators include assignment operators and logical operatorsGood wording.var found = (Value[i] = = = False);Good wording.if (found (Count > 10)) {DoSomething ();}Good wording.for (i = 0; i Process (i);}Bad wording: Lost spacevar found = (varlues[i]===false);
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.