9 programming habits of successful software developers 2

zhaozj2021-02-08  263

2. To properly use spaces and TAB keys C language, it is not distinguished, so the program can also write it all the time, but such a program will not understand "very difficult" program, please see The following example:

IF (x == 0) {a = b = c = D = max; x ;}

Write this, may save space, but not only others, it will be difficult to understand. The program is easy to understand!

IF (x == 0)

{

A = b = c = D = max;

X ;

}

Write like this, does it look clear? The program has to be exact spaces to understand.

3. Uniform use of braces and cutting methods

Each programmer has its own habits using braces ({}) and modified ways, so that when handing over to others, it will appear. For example, like the following example:

int main ()

{

INT x = 1;

INT Y = 10;

While (x

Printf ("Value of X IS% D / N", X);

X ;

}

}

Some programmers will write braces like this:

int main ()

{

INT x = 1;

INT Y = 10;

While (x

{

Printf ("Value of X IS% D / N", X);

X ;

}

}

The author is a second way. Because the beginning and end of a statement is obvious. We cannot ask each programmer to program in a way, but a program must be unified. Also, when you see the procedures for others, you can think of others' programming.

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

New Post(0)