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
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
1
380
高専、大学編入、そして未踏へ〜プロダクト開発とキャリアの歩み - Technical College, University Transfer, and On to “Mitou” / My Journey in Product Development and Career
pkmiya
0
130
Vibes Containers 〜AIで変わるコンテナ設計と運用〜
tkikuc
1
470
GKE アップグレード前に知っておきたい Blue/Green と PDB の関係
stkk
0
140
[PyCon KR 2026] More Variants, More Diversity for AI Accelerators
achimnol
0
130
Oxlintはいいぞ(続)
yug1224
1
540
FDEとは、何者なのか?
masapyon1212
0
140
From 6 People Classroom Meetup to 100 People Regional Conference / FOSS4G Hiroshima 2026
furukawayasuto
0
100
「つくるAI」だけではバグは見つからない ~テストに必要な「見つけるAI」を分離させる戦略~
mfunaki
0
230
リアルな遅延を測る仕様
kota_yata
1
140
Webエンジニアなのにブラウザの仕組みがわからないので、Pythonで自作してみた
tatsuki12
4
1.7k
AIは賢い。でも実行環境は? CLIおじさんがAI時代に伝えたいこと ~ CLIおじさんがAI時代に伝えたいこと ~
curekoshimizu
1
140
Featured
See All Featured
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
320
Into the Great Unknown - MozCon
thekraken
41
2.7k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
430
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
310
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
570
Being A Developer After 40
akosma
91
590k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
410
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
690
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.3k
Transcript
リファクタリング 既存のコードを安全に改善する 意図が伝わるコードの書き方
リファクタリングとは? • プログラムの振る舞い(仕様)を変えずに内部品質を向上させる作業 • 内部品質: 保守性、可読性等 • バグ修正ではない(リファクタリングとバグ修正は別で行う) • 実現方法:
カプセル化、関数化、名前の変更等
ロジックを関数化する目的とは? 1. 再利用性を高める(同じ処理を繰り返し書かない) 2. 可読性を上げる(行数を減らす) 3. 意図を明確にする(何をやっているかを読み手に伝える)
サンプルコード(リファクタリング前) ※ if文の条件が長くなると単純に読み辛く、理解しづらいという問題も つまりどういうことだってばよ?
サンプルコード(リファクタリング後) 曜日判定ロジックを 別関数に抽出 週末は割増料金になることをより明確に表現 ※ ユニットテストのしやすさも向上
関数命名のセオリー 「実装」と「意図」を分離する つまり「どうやって処理を行っているか」ではなく 「何をしているか」に着目して命名する × isDayOfWeekZeroOne() ◦ isWeekend()