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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
mazua
August 20, 2021
Programming
1
22k
refactoring
mazua
August 20, 2021
Tweet
Share
More Decks by mazua
See All by mazua
初めてのPHP.pdf
azuma
0
22k
Other Decks in Programming
See All in Programming
余白を設計しフロントエンド開発を 加速させる
tsukuha
7
2.1k
AgentCoreとHuman in the Loop
har1101
5
230
フロントエンド開発の勘所 -複数事業を経験して見えた判断軸の違い-
heimusu
7
2.8k
15年続くIoTサービスのSREエンジニアが挑む分散トレーシング導入
melonps
2
190
CSC307 Lecture 01
javiergs
PRO
0
690
AIによるイベントストーミング図からのコード生成 / AI-powered code generation from Event Storming diagrams
nrslib
2
1.9k
CSC307 Lecture 08
javiergs
PRO
0
670
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
520
[KNOTS 2026登壇資料]AIで拡張‧交差する プロダクト開発のプロセス および携わるメンバーの役割
hisatake
0
270
Grafana:建立系統全知視角的捷徑
blueswen
0
330
AIで開発はどれくらい加速したのか?AIエージェントによるコード生成を、現場の評価と研究開発の評価の両面からdeep diveしてみる
daisuketakeda
1
2k
Patterns of Patterns
denyspoltorak
0
1.4k
Featured
See All Featured
Rails Girls Zürich Keynote
gr2m
96
14k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
300
GraphQLとの向き合い方2022年版
quramy
50
14k
Discover your Explorer Soul
emna__ayadi
2
1.1k
Balancing Empowerment & Direction
lara
5
880
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.8k
BBQ
matthewcrist
89
10k
Agile that works and the tools we love
rasmusluckow
331
21k
Automating Front-end Workflow
addyosmani
1371
200k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.4k
Transcript
リファクタリング 既存のコードを安全に改善する 意図が伝わるコードの書き方
リファクタリングとは? • プログラムの振る舞い(仕様)を変えずに内部品質を向上させる作業 • 内部品質: 保守性、可読性等 • バグ修正ではない(リファクタリングとバグ修正は別で行う) • 実現方法:
カプセル化、関数化、名前の変更等
ロジックを関数化する目的とは? 1. 再利用性を高める(同じ処理を繰り返し書かない) 2. 可読性を上げる(行数を減らす) 3. 意図を明確にする(何をやっているかを読み手に伝える)
サンプルコード(リファクタリング前) ※ if文の条件が長くなると単純に読み辛く、理解しづらいという問題も つまりどういうことだってばよ?
サンプルコード(リファクタリング後) 曜日判定ロジックを 別関数に抽出 週末は割増料金になることをより明確に表現 ※ ユニットテストのしやすさも向上
関数命名のセオリー 「実装」と「意図」を分離する つまり「どうやって処理を行っているか」ではなく 「何をしているか」に着目して命名する × isDayOfWeekZeroOne() ◦ isWeekend()