9 programming habits of successful software developers 6

zhaozj2021-02-08  223

7. Being name to be rational programs, variables, procedure, Structure, etc. must be linked to its content, and the variables are not named "X", "Y", "Z".

Maybe you will say that the author uses X, Y, etc., the reason why the pen is doing this is that when he does not involve other programs, the author will certainly use meaningful variable names. Please see the example below:

Void X (Int A, INT B)

{

Int z;

z = a b;

Printf ("Z IS% D / N", Z);

}

Here, we can know what X does, but I don't know what it means. A, B, Z is also the same. Let us change it again and then look:

Void SUM_OF_AGES (INT JACKS_AGE, INT JILLS_AGE)

{

Int total_age;

Total_age = jacks_age jills_age;

Print ("TOTAL_AGE IS% D / N", TOTAL_AGE);

}

Although there is no comment, it is easy to see what to do. Good name, no comments can be.

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

New Post(0)