"C ++ Code Specification" revision instructions (1)

zhaozj2021-02-08  467

"C Coding Specification" revision

Directory P11:

In principle 23.22 The path used in the code is only "/" without using "/" ... 196

change to

In principle 23.22 The path used in the code is only "/" without using "/" ... 196

The body p1 countdown line 2:

Polymorphism: Parent class and subclasses can provide different implementations for the same interface (multiplexed), and external code can have different features without any changes (multiplexing).

change to

Polymorphism: Different subclasses can provide different implementations for the same parent interface (multiplexed), and external code can have different characteristics without any changes (multiplexing).

Text P6 Principle 1.2 About Variables and Functions

1.2.1 Description

... (see also see: "Principles 1.7 Prefix on anonymous namespace level identifier", ...)

change to

... (see also see: "Principles 1.7 About the prefix of global namespace level identifier", ...)

Text p9 principle 1.4 About macro, constant and template name

1.4.2 example

// Macro of constant class

#define Pie 3.1415926

// Function class macro

#define max (a, b) (/ * ... * /)

// constant

Const int layth = 1024;

// Member of the enumeration

change to

// Macro PIE of constant class

#define Pie 3.1415926

// Macro MAX of the function class

#define max (a, b) (/ * ... * /)

// constant Length

Const int layth = 1024;

// Members of Members in Blue, Red, White

(There are also a few similar addresses)

Text P12 principle 1.7 above

The reasonable naming method is definitely somewhere in these two extremes, but there is a specific judgment depending on your own judgment.

change to

The reasonable naming method is definitely somewhere in these two extremes, but there is a specific judgment depending on your own judgment. However, it is best to make advice inside an organization or department to facilitate everyone to understand each other.

Text P12 Principle 1.7 About Anonymous Name Space Level Identifies Prefix

Principle 1.7 About the prefix of anonymous namespace level identifier

1.7.1 description

An anonymous namespace level identifier is a public prefix (such as the Package name or library name, with a line), which is used to distinguish other Packet or library, etc. to provide similar functions.

The identifier in anonymous namespace refers to a global or file-level variable name, a constant name, macro, type name, and a function name.

change to

Principle 1.7 About the prefix of the global namespace level identifier

1.7.1 description

Give the global namespace (anonymous, global variable default, the following) level identifier a public prefix (such as the Package name or library name, padding), is used to distinguish other Packet or Library Wait.

The identifier in the global namespace refers to a global or file-level variable name, a constant name, a macro name, a type name, a function name, and the like.

Text P13 Principle 1.7 About the prefix of anonymous namespace level identifier

1.7.3 reasons

If you want the code to reuse, anonymous namespace level identifier needs to prevent naming conflicts.

change to

If you want the code to be multiplexed, the global namespace level identifier needs to prevent naming conflicts.

Text P13 Principle 1.8 Reduce anonymous namespace level identifier

Principle 1.8 Reduce anonymous namespace level identifier

1.8.1 description

Try to minimize identifiers such as anonymous namespace-class variables, constants, macros, and functions. ......

change to

Principle 1.8 Reduce the global namespace level identifier

1.8.1 description

Try to minimize identifiers such as global namespace-class variables, constants, macros and functions. ......

Text P13 Principle 1.8 Reduce anonymous namespace level identifier ...

1.8.2 example

Class CommonDefinition_t ...

{

PUBLIC:

Const float pie;

// ...

}

change to

1.8.2 example

Class CommonDefinition_t ...

{

PUBLIC:

Const float pie; // Now PIE is no longer global

// ...

}

Text P13 Principle 1.8 Reduce anonymous namespace level identifier

1.8.3 reasons

......

Shorten the life cycle, so that only within a limited time it should work, thereby reducing trouble: better, better maintenance, will not be misuse or abuse.

change to

Reduce its effective cycle / range, which exists only within a limited time / space it should function, thereby reducing trouble: better, better maintenance, will not be misuse or abuse.

Text P16 Principle 1.12 Try to name English

English is the most common language, especially in programming, other languages ​​(such as Chinese Pinyin) may cause difficulties in understanding readers.

change to

English is the most common language, especially in programming languages, other languages ​​(such as chose Chinese Pinyin) may cause the reader's understanding of understanding, and it is not conducive to greater code multiplexing.

Text P18 Principle 1.19 Avoiding letters or numbers in the shape of appearance in the name

example

/ *

* Letter O and digital 0 shapes are similar, avoid mixing;

* Avoid, it is best to write with lowercase, this is different from the number 0

* bigger

* /

change to

example

/ * ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -----------------

* Letter O and digital 0 shapes are similar, avoid mixing;

* Act avoided, the letter O is best to write with lowercase, so and number 0

* The difference is still bigger

* ------------------------------------------------- ---------------- * /

(In order to distinguish it, the annotation of this book is added to short and lower lines --------)

Text P26 principle 2.3 less floating point unless you must

Principle 2.3 less floating point unless you must

change to

Principle 2.3 Less floating point type unless you must

转载请注明原文地址:https://www.9cbs.com/read-273.html

New Post(0)