Comments make the code easier to read, but most engineers

Arpit Bhayani

Arpit Bhayani

Mar 27, 2023 β€’ 1 min read


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 πŸ‘‡β€

  1. mention what the function does in a line or two
  2. mention the assumptions made in the business logic
  3. mention any external services that the function is relying on
  4. mention known todos with reference to the associated ticket
  5. mention how your logic is using an algorithm or data structures
  6. mention the parameters, their types, and sample values
  7. 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.

Arpit Bhayani

Principal Engineer II at Razorpay - building Agent Studio, Ex-staff engg at GCP Memorystore & Dataproc, Creator of DiceDB, ex-Amazon Fast Data, ex-Director of Engg. SRE and Data Engineering at Unacademy. I spark engineering curiosity through my no-fluff engineering videos on YouTube and my courses