Should I use comments in code, liberally?

Everything,

Comment liberally or not? Pros and cons. I personally prefer to comment, because it leaves nothing for the fantasies of people reading it.

thanks

+3
source share
16 answers

In my experience, people who think their code is commenting is invariably wrong. You may remember why you did something in a certain way when you revise the code, but someone else who supports it will not.

If you need to do some research to write a piece of code, include a link or a note.

- , , , - .

, , ,

+5

" ". , , , , , .

, , , , , , , , , . , , , , , .

+3

, (a) (b) , , .

, , , .

, , .

+2

, .

, :

:

  • , , , .

  • , , , , , .

  • , - , , , , .

  • , , , .

, :

  • , , .

  • , .

, , , . , , .

+2

, , . , , . , , . , - .

.

//Copies a record 
//This function will copy the Src Record to the Dest Record 
void CopyRecord(Record *Dest,const Record *Src);

, - c ,

//
//This function will perform a shallow copy from the src record to the dest record 
//Dest pointer  must be null and allocation will occur inside function 
void CopyRecord(Record *Dest,const Record *Src);

, , , .

+2

, . , , .

+1

:

:

  • ,
  • , .
  • , , , .
  • , , , , .
+1

, , , .

+1

, O'Reilly 97 , (. Coders at Work).

,

+1

, , , , , . , , . .

0

, , . , , , .

, CS , , , . " " , , , , .

, , . , . script, , , .

0

, , .

-, , . , . , . on-line, .

-, . , , , , , , . ( , , , , , .)

-, , , . , , - . , , , ( ), . , , .

, , . , , , . , .

0

: "". , / , , , . , , , .

0

:

  • . , , , , .
  • -
0

( , ), , , . .: -)

, , . ( . , ?) , , "" (, , , ..)

0

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


All Articles