12

Any tips on how to properly document my code? I'm going to start my first internship soon so I need to learn it.

Comments
  • 9
    Clean Code Robert Martin
    Or how to self document the code
  • 1
    Plus there are document web site builders based on the scanned code and basically comments

    In python, Sphinx tool can generate documentation based on docstrings in Google style and other normal written pages in ReStructurizedText language
  • 2
    @atheist what about

    /**** Comment ends here ****/
  • 0
    I just put in ticket number/issue or doc link
  • 4
    Use variable names that explain themselves instead of letters, numbers, and/or abbreviations. Comment if you must but don't write essays.

    Read Clean Code
  • 1
    Document ONLY when you can’t express your intent through code.

    Instead of comments:
    Use meaningful variable names and method names and extract code blocks into methods like @atheist said.
    Break down long call chains into multiple lines and assign intermediate values to variables which give meaning to the intermediate steps.

    Don’t document just for the sake of documentation.
    Don’t document based on some stupid rules like everything that is public or everything that is a method.

    Automatically generated documentation is useless.

    Learn to write self documenting code.
Add Comment