: Re: Where do I start with C++ documentation? I am new to programming and am entirely self-taught. I have reached a point in my writing where a solid grasp of documentation standards would be greatly
Find a style guide and stick with it.
Style guides are more than just comments - they cover all parts of your code from how you name your variables to how you structure your code. Good style guides are designed to keep your code as maintainable as possible, with an emphasis on readability.
There are a number of style guides you can follow. Here is Google's C++ Style Guide. For the moment, you are mostly interested in the naming, commenting, and formatting sections, but you'll learn a lot from reading the other sections as well. Good style guides provide rules, explanations for why those rules exist, and examples.
The most important rule is to pick a style and stick with it. If you are consistent then both writing and reading your code becomes easier.
Quick and dirty rules of thumb
If you don't want to read through the style guide, my rule of thumb is that it should be possible to use a function without having to read the code. That means it should be completely comprehensible from the name and docstring. That usually means fully explaining what each of the arguments do, and that the return value means. If your code expects particular units (meters, seconds, etc), always describe what units you are using.
If, after returning to a piece of code after a little while doing something else, it takes you more than 10 seconds to figure out what a piece of code is doing or why it is doing that, add a comment.
More posts by @Pierce369
: Should I copyright my material before sending to my publisher? Should I copyright my material before sending to my publisher? Can they steal my content?
: Can I do small changes after the copyright of a novel? Can I do small changes after the copyright of a novel? My changes includes grammatical error, sentence reformation and fixing logical
Terms of Use Privacy policy Contact About Cancellation policy © selfpublishingguru.com2024 All Rights reserved.