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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
7
2.7k
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
3
490
週末にAI-DLCを本気で回したら$1,600溶けた
hbashimizu
0
130
XP祭りでしか伝わらないフリップネタ #xpjug
murabayashi
0
120
AIエージェント時代のコードレビューを設計する
nogu66
6
2.6k
Webの地図
yosuke_furukawa
PRO
4
3.7k
AI に Inclusive UI を書かせよう — Design Rules Skill で Compose UI を作り直す
theoriatec2024
1
460
不幸な GC
chencmd
0
890
高専キャリア LT 発表内容
crysta1221
6
5.6k
新卒PdEのリアル
ryu1013
1
480
ALB ログから Trace を気合で繋げる技術
fohte
7
880
市販E-Readerを乗っ取れ 〜Embedded Swiftで電子ペーパーガジェットを制御する〜
trickart
0
140
Featured
See All Featured
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
820
Crafting Experiences
bethany
1
310
The World Runs on Bad Software
bkeepers
PRO
72
12k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.8k
Designing Powerful Visuals for Engaging Learning
tmiket
1
540
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
290
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
480
Un-Boring Meetings
codingconduct
0
410
Context Engineering - Making Every Token Count
addyosmani
9
1.1k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
67
58k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
410
Transcript
リファクタリング 既存のコードを安全に改善する 意図が伝わるコードの書き方
リファクタリングとは? • プログラムの振る舞い(仕様)を変えずに内部品質を向上させる作業 • 内部品質: 保守性、可読性等 • バグ修正ではない(リファクタリングとバグ修正は別で行う) • 実現方法:
カプセル化、関数化、名前の変更等
ロジックを関数化する目的とは? 1. 再利用性を高める(同じ処理を繰り返し書かない) 2. 可読性を上げる(行数を減らす) 3. 意図を明確にする(何をやっているかを読み手に伝える)
サンプルコード(リファクタリング前) ※ if文の条件が長くなると単純に読み辛く、理解しづらいという問題も つまりどういうことだってばよ?
サンプルコード(リファクタリング後) 曜日判定ロジックを 別関数に抽出 週末は割増料金になることをより明確に表現 ※ ユニットテストのしやすさも向上
関数命名のセオリー 「実装」と「意図」を分離する つまり「どうやって処理を行っているか」ではなく 「何をしているか」に着目して命名する × isDayOfWeekZeroOne() ◦ isWeekend()