Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
誰のためのコメント? / comments-for-whom
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
yuki
January 09, 2025
Programming
0
110
誰のためのコメント? / comments-for-whom
【ペチオブ】2025年 新年会 書き初め LT
というイベントで発表したスライドです。
https://phper-oop.connpass.com/event/339339/
yuki
January 09, 2025
Tweet
Share
More Decks by yuki
See All by yuki
今年の抱負 2024/Aspirations for 2024
yyykms123
0
180
Vercel Ship まとめ「2023/5/1-5」
yyykms123
0
170
プロジェクト管理で失敗したこと
yyykms123
0
50
脱初心者のための GitHub Actions
yyykms123
0
320
プロジェクトをリリースするまでのプロセス
yyykms123
0
44
実務で使えるGitコマンド
yyykms123
4
1.2k
過去の自分へ送るLT!
yyykms123
0
94
Other Decks in Programming
See All in Programming
360° Signals in Angular: Signal Forms with SignalStore & Resources @ngLondon 01/2026
manfredsteyer
PRO
0
110
2026年 エンジニアリング自己学習法
yumechi
0
130
AI時代の認知負荷との向き合い方
optfit
0
140
Vibe codingでおすすめの言語と開発手法
uyuki234
0
220
IFSによる形状設計/デモシーンの魅力 @ 慶應大学SFC
gam0022
1
290
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
0
890
CSC307 Lecture 06
javiergs
PRO
0
680
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
150
CSC307 Lecture 08
javiergs
PRO
0
670
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
200
Oxlint JS plugins
kazupon
1
580
CSC307 Lecture 04
javiergs
PRO
0
650
Featured
See All Featured
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
79
Paper Plane
katiecoart
PRO
0
46k
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Technical Leadership for Architectural Decision Making
baasie
1
240
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
180
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
0
1.8k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
420
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
110
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Thoughts on Productivity
jonyablonski
74
5k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
62
Transcript
誰のためのコメント? 【ペチオブ】2025年 新年会 書き初めLT 2025.01.09 / Yukimasa Ikeda
目次 1. コメントがないコード 2. 過剰なコメント 3. 意図が伝わらないコメント 4. 理想のコメント 2
1. コメントがないコード function a() { execute(); } 「何をする関数か全く分からない…」 このコードを書いた本人に3年後に聞いても「たぶん緊急対応だった」と返される かも。
コメントがないコードの問題 チームで開発している場合、他のメンバーがコードの意図を理解できない。 自分自身でも時間が経つと記憶が曖昧になる。 3
2. 過剰なコメント 実況中継のようなコメントは、逆にノイズになります。 // ループ処理を開始します for (let i = 0;
i < items.length; i++) { process(items[i]); } 「見れば分かる!」と思わずツッコミたくなる。 コメントを書くこと自体が目的になっているケース。 過剰なコメントの問題 コードが変わってもコメントが更新されず矛盾が生じる。 コメントが増えるほど、意図を探すのが困難になる。 4
3. 意図が伝わらないコメント よくある例: 「TODO: 後で直す」 // TODO: 後で直す const result
= doSomething(); なぜ後で直す必要があるのか? どんな状況を想定しているのか? 意図が伝わらないコメントの問題 他人や未来の自分が見ても、何をしたかったのか分からない。 修正のタイミングや優先度が曖昧になる。 5
4. 理想のコメント コメントを書く際は、以下のポイントを押さえるべきです。 1. 目的を説明する: 「この処理が必要な理由は何か?」を明確にする。 2. 意図を明確にする: 「この方法を選んだ背景は何か?」を伝える。 3.
背景を書く: 設計のトレードオフや、特定の仕様に対応した経緯などを補足する。 理想のコメントの例 // ユーザー一覧を取得する際にページネーションを行うため // クエリにlimitとoffsetを追加しています const users = fetchUsers({ limit: 10, offset: 20 }); 6
まとめ コメントは未来の自分や他人に向けて書く。 ただし、コード自体が意図を伝えられるなら、不要なコメントは書かない。 コメントの量より、質が重要。 7
書き初め 8