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
refactoring
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
mazua
August 20, 2021
Programming
22k
1
Share
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
10年分の技術的負債、完済へ ― Claude Code主導のAI駆動開発でスポーツブルを丸ごとリプレイスした話
takuya_houshima
0
1.8k
Coding as Prompting Since 2025
ragingwind
0
760
今からFlash開発できるわけないじゃん、ムリムリ! (※ムリじゃなかった!?)
arkw
0
190
3分でわかるatama plusのQA/about atama plus QA
atamaplus
0
110
「速くなった気がする」をデータで疑う
senleaf24
0
150
The free-lunch guide to idea circularity
hollycummins
0
420
安いハードウェアでVulkan
fadis
1
920
PHPのバージョンアップ時にも役立ったAST(2026年版)
matsuo_atsushi
0
290
夢の無限スパゲッティ製造機 -実装篇- #phpstudy
o0h
PRO
0
190
年間50登壇、単著出版、雑誌寄稿、Podcast出演、YouTube、CM、カンファレンス主催……全部やってみたので面白さ等を比較してみよう / I’ve tried them all, so let’s compare how interesting they are.
nrslib
4
720
LM Linkで(非力な!)ノートPCでローカルLLM
seosoft
0
410
それはエンジニアリングの糧である:AI開発のためにAIのOSSを開発する現場より / It serves as fuel for engineering: insights from the field of developing open-source AI for AI development.
nrslib
1
830
Featured
See All Featured
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.8k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
470
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
260
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
710
How STYLIGHT went responsive
nonsquared
100
6k
GitHub's CSS Performance
jonrohan
1032
470k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Designing Powerful Visuals for Engaging Learning
tmiket
1
330
Transcript
リファクタリング 既存のコードを安全に改善する 意図が伝わるコードの書き方
リファクタリングとは? • プログラムの振る舞い(仕様)を変えずに内部品質を向上させる作業 • 内部品質: 保守性、可読性等 • バグ修正ではない(リファクタリングとバグ修正は別で行う) • 実現方法:
カプセル化、関数化、名前の変更等
ロジックを関数化する目的とは? 1. 再利用性を高める(同じ処理を繰り返し書かない) 2. 可読性を上げる(行数を減らす) 3. 意図を明確にする(何をやっているかを読み手に伝える)
サンプルコード(リファクタリング前) ※ if文の条件が長くなると単純に読み辛く、理解しづらいという問題も つまりどういうことだってばよ?
サンプルコード(リファクタリング後) 曜日判定ロジックを 別関数に抽出 週末は割増料金になることをより明確に表現 ※ ユニットテストのしやすさも向上
関数命名のセオリー 「実装」と「意図」を分離する つまり「どうやって処理を行っているか」ではなく 「何をしているか」に着目して命名する × isDayOfWeekZeroOne() ◦ isWeekend()