<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/best-practices-for-writing-code-comments-ylopuoese" -->

---
title: Best practices for writing code comments | daily.dev
description: Comments are important because they help programmers make sense of code. A bad comment is worse than no comment at all, but it's hard to measure the quality of...
canonical: https://daily.dev/posts/best-practices-for-writing-code-comments-ylopuoese
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Best practices for writing code comments | daily.dev
og:description: Comments are important because they help programmers make sense of code. A bad comment is worse than no comment at all, but it's hard to measure the quality of...
og:url: https://daily.dev/posts/best-practices-for-writing-code-comments-ylopuoese
og:image: https://api.daily.dev/og/posts/yloPuoESe.png
og:image:alt: Best practices for writing code comments
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Best practices for writing code comments

**[Stack Overflow Blog](https://daily.dev/sources/stackov)** · 8 min read · 23 upvotes · 2 comments

## Summary

Comments are important because they help programmers make sense of code. A bad comment is worse than no comment at all, but it's hard to measure the quality of comments. Comments should not duplicate the code and should not excuse unclear code. Comments that add no information have negative value because they add visual clutter.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://stackoverflow.blog/2021/12/23/best-practices-for-writing-code-comments/>

## Community discussion

Top comments from developers on daily.dev.

**@formyapp** · 0 upvotes

> Never knew that are best practices for comment. Glad I found this article. Everyone should read this article

**@xantosromero** · 0 upvotes

> Comments are very important on the code. Fabolous article, great job friend.

---

Tags: [#general-programming](https://daily.dev/tags/general-programming)

[View this post on daily.dev](https://daily.dev/posts/best-practices-for-writing-code-comments-ylopuoese)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Best practices for writing code comments","url":"https://daily.dev/posts/best-practices-for-writing-code-comments-ylopuoese","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/best-practices-for-writing-code-comments-ylopuoese"},"datePublished":"2021-12-23T14:49:05.185Z","dateModified":"2021-12-23T14:49:05.185Z","description":"Comments are important because they help programmers make sense of code. A bad comment is worse than no comment at all, but it's hard to measure the quality of...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/c168764647b12f8a4929d79600894693","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/c168764647b12f8a4929d79600894693","isAccessibleForFree":true,"articleSection":"Stack Overflow Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Stack Overflow Blog","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/003e14873238469caea60ebdd34508ae","url":"https://daily.dev/sources/stackov"},"commentCount":2,"discussionUrl":"https://daily.dev/posts/best-practices-for-writing-code-comments-ylopuoese","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":23},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":2}],"keywords":"general-programming","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Stack Overflow Blog","item":"https://daily.dev/sources/stackov"},{"@type":"ListItem","position":3,"name":"Best practices for writing code comments"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/best-practices-for-writing-code-comments-ylopuoese","comment":[{"@type":"Comment","text":"Never knew that are best practices for comment. Glad I found this article. Everyone should read this article","datePublished":"2021-12-30T03:52:45.860Z","url":"https://daily.dev/posts/yloPuoESe#c-GQaKEcVLa","author":{"@type":"Person","name":"Raj Kiran Chaudhary","url":"https://daily.dev/formyapp","image":"https://avatars0.githubusercontent.com/u/42111832?v=4"}},{"@type":"Comment","text":"Comments are very important on the code. Fabolous article, great job friend.","datePublished":"2021-12-25T20:21:11.130Z","url":"https://daily.dev/posts/yloPuoESe#c-KNF7klRLG","author":{"@type":"Person","name":"Santos Romero","url":"https://daily.dev/xantosromero","image":"https://media.daily.dev/image/upload/s--1dl0yGh1--/f_auto/v1711120743/avatars/avatar_cEU-mTLhp"}}]}
```

