Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
より良いコードの書き方(初級編)
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
muzun
February 24, 2015
Education
340
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
より良いコードの書き方(初級編)
リーダブルコード第一部
muzun
February 24, 2015
Transcript
12 slides
よりよいコードの書き方 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 • ここでの紹介事例は本書の 一例ですので一読を推奨
More Decks by muzun
See All by muzun
PRML 6章 カーネル法@長岡
muzun
0
1.6k
Other Decks in Education
See All in Education
生成AIとの付き合い方/ How to work with AI
kaityo256
PRO
3
1.2k
Liburd and Stoll Farrell "Copyright Essentials From A to AI: A 2026 NISO Training Series, Session Five: Open Movements & Author Rights"
baltimoreniso
0
240
Unit 4: Introduction to Software Development Life Cycle
sonakv
0
120
Session 7 - Teknik Lobby dan Negosiasi
adeputra13
0
290
Sekolah Sabat - Triwulan 4 2026 - Pelajaran 6
hiola
0
9.4k
Padlet opetuksessa
matleenalaakso
12
16k
DRONEGEOGRAFÍA: INNOVACIÓN DIDÁCTICA Y FOTOGRAMETRÍA 3D PARA LA COHESIÓN TERRITORIAL Y LA CIUDADANÍA ACTIVA
juanmartin2026
0
61k
2026年度秋学期 統計学 第8回(オンデマンド配信回) 演習(1)・問題に対する答案の書き方 (2026. 11. 17)
akiraasano
PRO
0
110
Sekolah Sabat - Triwulan 4 2026 - Pelajaran 2
hiola
0
11k
クオリティエンジニアリング ーゲームの品質を支えるエンジニアー
segadevtech
2
1.6k
Liburd and Stoll Farrell "Copyright Essentials From A to AI: A 2026 Training Series, Session Six: Licensing & Market Power"
baltimoreniso
0
150
【2028卒向け:デザイナー就活講座】キャリアスタートセミナー_Designer Lab_長谷部 航平
koheihasebe
0
290
Featured
See All Featured
Music & Morning Musume
bryan
48
7.5k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
470
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
WENDY [Excerpt]
tessaabrams
15
41k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
550
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
370
Everyday Curiosity
cassininazir
0
420
Writing Fast Ruby
sferik
630
63k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
540
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
480