Comments make the code easier to read, but most of

Arpit Bhayani

Arpit Bhayani

Feb 05, 2024 β€’ 1 min read


Comments make the code easier to read, but most of the comments are quite obvious πŸ€¦β€β™‚οΈ

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 referencing 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

Every single function need not be commented on in such an exhaustive way, but the critical functions cannot afford to have blind spots.

⚑ I keep writing and sharing these engineering nuggets, so if you are keen on learning them, follow along.

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