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
より良いコードの書き方(初級編)
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
muzun
February 24, 2015
Education
0
330
より良いコードの書き方(初級編)
リーダブルコード第一部
muzun
February 24, 2015
Tweet
Share
More Decks by muzun
See All by muzun
PRML 6章 カーネル法@長岡
muzun
0
1.6k
Other Decks in Education
See All in Education
ブランチ操作 / 02-a-branch
kaityo256
PRO
0
190
Security, Privacy and Trust - Lecture 11 - Web Technologies (1019888BNR)
signer
PRO
0
3.3k
インシデント対応
akira345
0
280
2025年の本当に大事なAI動向まとめ
frievea
1
200
0203
cbtlibrary
0
140
Blueprint for Strengthening Community Colleges Training Grant Success
territorium
PRO
0
120
The Next Big Step Toward Nuclear Disarmament
hide2kano
0
290
Padlet opetuksessa
matleenalaakso
12
15k
AIで日本はどう進化する? 〜キミが生きる2035年の地図〜
behomazn
0
130
Data Representation - Lecture 3 - Information Visualisation (4019538FNR)
signer
PRO
1
2.9k
Gitの仕組みと用語 / 01-b-term
kaityo256
PRO
0
190
バージョン管理とは / 01-a-vcs
kaityo256
PRO
1
200
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
46
8.1k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.5k
How to make the Groovebox
asonas
2
2k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.2k
WENDY [Excerpt]
tessaabrams
9
36k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
340
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
0
160
Faster Mobile Websites
deanohume
310
31k
The Invisible Side of Design
smashingmag
302
51k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
Transcript
よりよいコードの書き方 1 / 12 1 よりよいコードの書き方 (初級編) 2015年2月24日 発表 岩橋研究室M1
木村 大輝
よりよいコードの書き方 2 / 12 2 読みやすいコードを書こう
よりよいコードの書き方 3 / 12 3 なぜ読みやすいコード? • プログラミングは共同作業 • 半年後の自分は他人
よりよいコードの書き方 4 / 12 4 気をつける点 ✔ 明確な名前 ✔ 整ったコード
✔ コードの意図をコメント
よりよいコードの書き方 5 / 12 5 明確な名前をつける tmp = (1 -
a) * d + a * s; ダメな例 変数名tmp, a, d, sが何を表しているのか分からない
よりよいコードの書き方 6 / 12 6 明確な名前をつける mixed_value = (1 -
ratio) * dest_value + ratio * src_value; 良い例 → 値を混合するコードだと推測できる
よりよいコードの書き方 7 / 12 7 整ったコードを書く details = argv[1] location
= argv[2] phone = argv[3] emal = argv[4] url = aergv[5] ダメな例 タイプミスしている
よりよいコードの書き方 8 / 12 8 整ったコードを書く details = argv[1] location
= argv[2] phone = argv[3] emal = argv[4] url = aergv[5] タイプミスしている 良い例
よりよいコードの書き方 9 / 12 9 コメントにコードの意図を書く // 重みで割る value =
value / weight; ダメな例 コメントがなくてもコードを見れば理解できる
よりよいコードの書き方 10 / 12 10 コメントにコードの意図を書く // 複数枚の画像から ratio の割合で合成
for (…) { (valueに対する繰り返し処理) weight = weight + ratio[i]; } value = value / weight; 良い例 →コメントは処理の目的を理解することを助ける
よりよいコードの書き方 11 / 12 11 まとめ 書いたコードが 読み手にとって理解しやすいか を考えよう!
よりよいコードの書き方 12 / 12 12 出典 • リーダブルコード ▶ Dustin
Boswell (著) ▶ Trevor Foucher (著) ▶ より良いコードを書くための シンプルで実践的なテクニック ▶ http://www.amazon.co.jp/dp/4873115655 • ここでの紹介事例は本書の 一例ですので一読を推奨