datacarpentry / stata-economics

Economics Lesson with Stata
https://datacarpentry.org/stata-economics/
Other
27 stars 20 forks source link

Introduce how to write comments in .do files #101

Open korenmiklos opened 2 years ago

yuanyuan0314 commented 1 year ago

Hi~I hope I didn't misunderstand this prompt. For writing comments, I commonly use three different marks: /*/, //, . I think there are also some tricks to make the do-files readable. There are four things I usually do:

  1. At the beginning of the do-file, I list the updated date, the goal, and the structure of this do-file.
  2. I use a whole line of * to separate each "chapter" of the do-file.
  3. I use // to write the purpose of some lines if it is not straightforward.
  4. I use /**/ to save the results of some important lines below the lines themselves. For example, I will store the results of _merge for future reference without rerunning the codes.

Those tricks are very personalized. It might be too redundant. But it should be helpful for archiving finished projects. It might take a while to review a small part of the codes without comments.

Thank you!

korenmiklos commented 1 year ago

Thank you, @yuanyuan0314 . Do you want to add this to https://github.com/datacarpentry/stata-economics/blob/main/_episodes/05-programming.md and submit a pull request?