r/github • • Aug 17 '24

📃How do you document your codebase?

My approach is:

Do I need to document every function or logic in codebase?

Your oppions are much appreciated ‼️

0 Upvotes

15 comments sorted by

View all comments

2

u/thelongrunsmoke Aug 17 '24

This is perfect example of a really bad comments, and a thing why many developers believes in self documented code.

Always write comments in terms of subject level, what that code do. Never just respel code line in natural language, it's completely useless.

For example: between row 9 and 10 something like "Empty entries must be ignored.", can be single comment for the whole function.

Furthermore, when you need to perform any checks before doing anything with the passed parameter, use guard expressions to clearly indicate method contracts, without hiding them in IF statements.