DEV Community

Discussion on: Commenting: where?

Collapse
 
jancis38 profile image
jancis38

You read the code top to bottom.
Why would you put the comment below? Are you crazy?!

Collapse
 
vulcanwm profile image
Medea

So you know what the code above shows?

Collapse
 
cappe987 profile image
Casper

I think a lot of languages and developers follow the convention of putting comments before code. I think it makes more sense because if you go to read a large block of code you first want it explained (the "why's" of the code) before reading the code itself. You typically want something explained to you before you try to understand it, and top-to-bottom is the natural reading direction. For a large code block you might even miss it if it is at the end.