freeCodeCamp/guide/english/documentation/index.md

32 lines
2.7 KiB
Markdown
Raw Normal View History

---
title: Code documentation
---
## Code Documentation
2018-12-07 08:57:39 +00:00
Code Documentation allows other developers (and yourself) to understand/remember the customs and purposes of particular pieces of code. It is recommended to use documentation before debugging your code, this helps you to debug effectively.
2018-12-07 08:57:39 +00:00
For example, if you happen to pass along your code to an absolute beginner, they should be able to follow along through comments, appropriate variable names and that means structuring the code in a readable manner.
2018-12-07 08:57:39 +00:00
It is extremely important to make a habit out of commenting your functions, loops, and declarations and treating comments as part of the source code, just as regular code should be.
Many developers have probably learned that it is much harder to go back through your code and comment it after you finish. It's always a good idea to label and comment your code as you go, so that you don't forget or mix up what certain variables or functions do.
2018-11-20 05:57:15 +00:00
Think of Code documentation as a history textbook. It allows current developers to keep tabs on their progress, as well as to educate future developers. Use it not only as a learning tool, but also as a reminder. As George Santayana once said, "Those who do not read history are doomed to repeat it!"
2018-11-05 04:08:44 +00:00
2018-12-07 08:57:39 +00:00
![An example of commenting in the real world](https://cdn-images-1.medium.com/max/1620/1*Pyxsc7Uixbitv5myywaA_Q.jpeg)
Even though the code itself should always be self explanatory, it is often good to have a document along with the code files that describes it into more detail. The idea of such a document is not only to cover the technical parts so that contributors are able to add or change the code but also for people wanting to use the program. For that reason, it is for example good to have a guide on how to use the created program and some examples along with it. Documents become especially important for bigger projects since it can be a lot more time consuming and complicated to understand a program by just reading its code compared to an explanatory document.
If the program uses already existing material such as libraries or is based on some other projects, it is always a good idea to mention those in the document since it is part of the foundation.
#### More Information
2018-12-07 12:34:05 +00:00
* [Medium Article about Code Documentation](https://medium.com/@andrewgoldis/how-to-document-source-code-responsibly-2b2f303aa525)
2018-12-07 12:34:05 +00:00
* [Code Tuts top 15 Best Practices](https://code.tutsplus.com/tutorials/top-15-best-practices-for-writing-super-readable-code--net-8118)
2018-12-07 12:34:05 +00:00
* [Medium Article "The Good, The Bad, The Ugly"](https://medium.freecodecamp.org/code-comments-the-good-the-bad-and-the-ugly-be9cc65fbf83)
2018-12-07 12:34:05 +00:00
* [Medium Article about "Writing great documentation"](https://medium.com/@episod/writing-great-documentation-44d90367115a)