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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
AI Assistants for Your Angular Solutions
manfredsteyer
PRO
0
140
PHPのバージョンアップ時にも役立ったAST(2026年版)
matsuo_atsushi
0
120
The free-lunch guide to idea circularity
hollycummins
0
270
DevinとClaude Code、SREの現場で使い倒してみた件
karia
1
1.1k
Codex の「自走力」を高める
yorifuji
0
1.2k
nuget-server - あなたが必要だったNuGetサーバー
kekyo
PRO
0
270
野球解説AI Agentを開発してみた - 2026/02/27 LayerX社内LT会資料
shinyorke
PRO
0
340
PostgreSQL を使った快適な go test 環境を求めて
otakakot
0
560
Swift ConcurrencyでよりSwiftyに
yuukiw00w
0
270
maplibre-gl-layers - 地図に移動体たくさん表示したい
kekyo
PRO
0
290
go directiveを最新にしすぎないで欲しい話──あるいは、Go 1.26からgo mod initで作られるgo directiveの値が変わる話 / Go 1.26 リリースパーティ
arthur1
2
560
CSC307 Lecture 14
javiergs
PRO
0
470
Featured
See All Featured
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
200
Test your architecture with Archunit
thirion
1
2.2k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Building AI with AI
inesmontani
PRO
1
800
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.3k
Paper Plane
katiecoart
PRO
0
48k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.2k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
150
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.2k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
180
Transcript
リファクタリング 既存のコードを安全に改善する 意図が伝わるコードの書き方
リファクタリングとは? • プログラムの振る舞い(仕様)を変えずに内部品質を向上させる作業 • 内部品質: 保守性、可読性等 • バグ修正ではない(リファクタリングとバグ修正は別で行う) • 実現方法:
カプセル化、関数化、名前の変更等
ロジックを関数化する目的とは? 1. 再利用性を高める(同じ処理を繰り返し書かない) 2. 可読性を上げる(行数を減らす) 3. 意図を明確にする(何をやっているかを読み手に伝える)
サンプルコード(リファクタリング前) ※ if文の条件が長くなると単純に読み辛く、理解しづらいという問題も つまりどういうことだってばよ?
サンプルコード(リファクタリング後) 曜日判定ロジックを 別関数に抽出 週末は割増料金になることをより明確に表現 ※ ユニットテストのしやすさも向上
関数命名のセオリー 「実装」と「意図」を分離する つまり「どうやって処理を行っているか」ではなく 「何をしているか」に着目して命名する × isDayOfWeekZeroOne() ◦ isWeekend()