The main question about the code template

HI, I have a simple question, I asked 3-4 different people and had different answers from each of them.

Which code is better suited and used more?

Is this important if agreed?

What is considered the best practice in the world of working as a programmer?

For instance,

AND)

for(int i=0;i<8;i++)
{
    for(int p=0;p<8;p++)
    {
        if(array[i][p]->Equals(String))
        {
                    //Do Stuff
        }
    }
}

OR

AT)

for(int i=0;i<8;i++){
 for(int p=0;p<8;p++){
  if(array[i][p]->Equals(String)){
                    //Do Stuff
                }
        }
}

Thanks Tim

+3
source share
8 answers

There are several published style guides - for example, Google is here , and it functions as:

ReturnType ClassName::FunctionName(Type par_name1, Type par_name2) {
  DoSomething();
  ...
}

and for blocks:

if (condition) {  // no spaces inside parentheses
  ...  // 2 space indent.
} else {  // The else goes on the same line as the closing brace.
  ...
}

with similar examples for other blocks.

, , , - , ", X" ( X Google, geosoft , ( ).

+1

: , , . , , , , .

, , GCC FSF, , "{" . , "", . .

+1

. .

0

. /.

, B, A.

, "" "", B, . , .

0

, ? , () ?

, .

, . .

- - . IDE. Eclipse, , , .

, . , .

0

, , , .

, , , , , , .

, . .

, , ( , ).

, YMMV.

0

, , .

, , , . , , . , , IDE.

0

, , , , .

, . , , .

, .

, , identifiers_with_underscored_spacing, , IdentifiersWithCamelCaseWordBreaks.

, , , .

, , .

0

Source: https://habr.com/ru/post/1735357/


All Articles