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
refactoring
Search
mazua
August 20, 2021
Programming
22k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
refactoring
mazua
August 20, 2021
More Decks by mazua
See All by mazua
初めてのPHP.pdf
azuma
0
22k
Other Decks in Programming
See All in Programming
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
270
そのリトライ、死んだコネクションを使い回していませんか ── GoのHTTPクライアントとHTTP/2を実プロダクト障害から学び直す
myus4a
0
350
AHC070解法紹介
eijirou
0
150
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
1
2k
App Storeの外へ──日本のiOSサイドローディング入門 for iOSDC Japan 2026
yuukiw00w
0
280
AGENTS.md Is Not Enough:Build Skills, Don't Download Them
lx_t
0
130
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
580
Intent as Code
shoppingjaws
6
1.1k
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
450
選挙速報を多くのユーザーへ 届ける Live Activities 設計
hamayokokuririn
0
190
Verilogで学ぶCPU自作入門.pdf
uyuki234
7
3.9k
setup-vp GitLab対応の裏側
naokihaba
0
140
Featured
See All Featured
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
250
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.8k
Paper Plane (Part 1)
katiecoart
PRO
2
11k
Statistics for Hackers
jakevdp
799
230k
Un-Boring Meetings
codingconduct
0
440
Documentation Writing (for coders)
carmenintech
77
5.6k
Embracing the Ebb and Flow
colly
88
5.2k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
Designing Powerful Visuals for Engaging Learning
tmiket
1
580
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
550
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
290
Transcript
リファクタリング 既存のコードを安全に改善する 意図が伝わるコードの書き方
リファクタリングとは? • プログラムの振る舞い(仕様)を変えずに内部品質を向上させる作業 • 内部品質: 保守性、可読性等 • バグ修正ではない(リファクタリングとバグ修正は別で行う) • 実現方法:
カプセル化、関数化、名前の変更等
ロジックを関数化する目的とは? 1. 再利用性を高める(同じ処理を繰り返し書かない) 2. 可読性を上げる(行数を減らす) 3. 意図を明確にする(何をやっているかを読み手に伝える)
サンプルコード(リファクタリング前) ※ if文の条件が長くなると単純に読み辛く、理解しづらいという問題も つまりどういうことだってばよ?
サンプルコード(リファクタリング後) 曜日判定ロジックを 別関数に抽出 週末は割増料金になることをより明確に表現 ※ ユニットテストのしやすさも向上
関数命名のセオリー 「実装」と「意図」を分離する つまり「どうやって処理を行っているか」ではなく 「何をしているか」に着目して命名する × isDayOfWeekZeroOne() ◦ isWeekend()