How do you write code that is easy to read by other people and who does not have the right to write any part of it?
The best way to make sure others read your code is to make sure that it is clear and concise. Namely,
, , , .
, StackOverflow, FAQ
?, , . , !
?
, , . , !
:
// add one to the count: i++;
int x = i + j; int runSum = prevSum += newValue;
, :
if (x == y) { z = a; } else { z = b; } z = (x == y) ? a : b;
Clean Code . . .
, , , , , . , , Test Driven Development, , , , , , , "".
, , , . - , .
, . , , (, , foreach, , ).
( ), , .
Code Complete 2. / .
, , ! . , . , , :
: , , , , , , , . .
: , , . , .
: , . , .
. . @rmbarnes, Code Complete 2. " " Kent Beck - .
, , , , , . , , . Code Complete, , , .
, - . , .
, . , , , . . -.
, , . -, , - .
- . , , .
: . , , . , " , , " . , , .
, , , . . , HD , .
int total = 10; int sum = 0; for (int i = 0; i < total; i++) { sum += i; } // Next coding statement is a space below the bracket return sum;
int total = 10;int sum = 0; for (int i = 0; i < total; i++) { sum += i; } return sum;
, , . if. , .
if(true) // some action if(true) { // Some action }
- , . , , , , .
, - , . , (/ ..), , 10 , . Doxygen/Javadocs 10-15 , - .
100% , , / .
, , , , .