📜 ⬆️ ⬇️

Code that is nice to read

Good code


There are many requirements for a good code: it must be optimal, it must have unit tests, it must be easy to reuse, it must conform to the company's code-standard and the spirit of the language. And it should be nice to read.
I would like to talk about the rules that help me make the code readable.

Basic rule

I believe that the code is readable, in which you can not get a grasp.
That is, two or three lines should be enough to say what a class or method does. Two-three more - to say about how he does it.

Other comments

, , .

1.   « ?» — , , . , , . , .

2. 200-300    , : , .
, ( ) . , , , . — CommonUtils ( common_utils.h).

3.    . , IDE .

4.    . , .
, «retrieve», «fetch», «get», «helper», «utils», «controller».

5.    . , , , .
, . . — , .

6.    , . , , .
, , , ( , , ).

7.    , , , , , .
, . , . , , , IO-, - .

8.   , . 5-10 : Fix for bug 24132.
, , . « 5-10 ?» .


:

Code Sample


?
? ?

')

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


All Articles