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
XHTMLが残したもの
yosuke_furukawa
PRO
2
760
変化を抱擁するドキュメントの作り方 - ビジネスルール駆動開発がもたらす、コードとの新しい関係
ioki
2
170
App Intentsのビルドプロセスを支える技術
kntkymt
0
330
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
100
AI × TiDD / 2026.09.05 Redmine 大阪
tokudiro
1
140
XP祭りでしか伝わらないフリップネタ #xpjug
murabayashi
0
150
スマート反転とウェブアクセシビリティ
camiha
0
200
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
380
AIを上手に使っていこうとしたら越境せざるを得なくなった話 〜実践1年で見えた境界を越えなければならない理由と進め方〜 / Crossing borders with AI
tomoyakitaura
4
1.1k
Swift愛好会と私(ウホーイ) / Swift Fan Club and Uhooi
uhooi
0
150
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
250
cdk deploy JawsSonic #MARATHONしながらAWSリソースをデプロイしてみよう
akihisaikeda
2
110
Featured
See All Featured
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.2k
Faster Mobile Websites
deanohume
310
32k
エンジニアに許された特別な時間の終わり
watany
108
250k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
500
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
230
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
350
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.6k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
850
The Cost Of JavaScript in 2023
addyosmani
55
10k
Transcript
リファクタリング 既存のコードを安全に改善する 意図が伝わるコードの書き方
リファクタリングとは? • プログラムの振る舞い(仕様)を変えずに内部品質を向上させる作業 • 内部品質: 保守性、可読性等 • バグ修正ではない(リファクタリングとバグ修正は別で行う) • 実現方法:
カプセル化、関数化、名前の変更等
ロジックを関数化する目的とは? 1. 再利用性を高める(同じ処理を繰り返し書かない) 2. 可読性を上げる(行数を減らす) 3. 意図を明確にする(何をやっているかを読み手に伝える)
サンプルコード(リファクタリング前) ※ if文の条件が長くなると単純に読み辛く、理解しづらいという問題も つまりどういうことだってばよ?
サンプルコード(リファクタリング後) 曜日判定ロジックを 別関数に抽出 週末は割増料金になることをより明確に表現 ※ ユニットテストのしやすさも向上
関数命名のセオリー 「実装」と「意図」を分離する つまり「どうやって処理を行っているか」ではなく 「何をしているか」に着目して命名する × isDayOfWeekZeroOne() ◦ isWeekend()