Comments make the code easier to read, but most engineers write very obvious comments like
Ex: the function βfetch_urlβ - fetches the URL π€¦ββοΈ
Here are a few pointers around writing 10x better comments πβ
- mention what the function does in a line or two
- mention the assumptions made in the business logic
- mention any external services that the function is relying on
- mention known todos with reference to the associated ticket
- mention how your logic is using an algorithm or data structures
- mention the parameters, their types, and sample values
- mention an example usage of the function
Note: Every single function need not be commented on in such an exhaustive way, but the critical functions sure does.
A critical function of a microservice or product powers key business-critical features and hence we cannot afford to have any blind spots.