Is the sudden appearance of an unbearable desire to write some comments a sign of poor design?

Imagine ... You wrote the code; implemented some interfaces, used some design patterns, passed many unit tests, extracted many methods for refactoring and so on. You developed, developed, developed ... But at some mysterious moment, for some reason, you, something inside of you, began to whisper to you that you should write a comment now. Something hurts you that if you do not write a comment, something will be absent, or something may not be completely clear ...

Then you will comment on your code !: (

Could this be a secret sign of poor design?

If you find that if you do not comment on your code at this spiritual (!) Moment, it will not fulfill its mission ; can we consider it a reliable "strong" symptom of a possible poor design in your code?

+3
source share
10 answers

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

+5

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

, , , .

. , .

-. , , . ...

+3

, , , , . , . javadocs.

+2

, , , , , .

+1

annwer, . :

, - , . , - , .

+1

, , , , , : , , . (, , ) , . .

+1

Dittos . , , , .

, , , . , :

x17=bbq*rg; // Multiply price by tax rate to get tax amount

:

taxAmount=price*taxRate;

, - , , , . , , :

x=x+1; // Add one to x

, , , , "+". , , Google.

, , , :

  • , . -, , , . : "// , , , ". , , , , , , . , , . .

  • , , API . : " , contactPricingServer , getPrice , , , , closeConnection, ". , , , , . .

  • , : , , . : " , , ". , - , , , - , . , , . , X, Y, Y , .

Update

. , , , , , - , , , :

// Set the sales status to "S" and the delivery date to today.
setSalesStatus("S");
setDeliveryDate(today);

, , . . , , , , , ? , . , , , , - . Arggh.

+1

.., . , , - , . - , , : " ?" , . , , .

, , , .

+1

. , ,

// parser starts here
...
// mail!

.

, 5 script, ... .

, , . - , . , .

0

- . . ( ) .

, . , - , .

.

0
source

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


All Articles