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
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
symfony/aiとlaravel/boost
77web
0
110
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
190
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
270
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
250
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
460
1B+ /day規模のログを管理する技術
broadleaf
0
120
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.6k
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
210
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
810
技術記事、 専門家としてのプログラマ、 言語化
mizchi
14
7.2k
SLOをサービス品質の共通言語にするために 取り組んできたこと
wakana0222
0
250
AIキャラアプリkaiwaの低遅延音声通話基盤をどう作ったか - AWS Gravitonで支える低遅延・低コストAI Agent基盤
mogamit
0
150
Featured
See All Featured
Technical Leadership for Architectural Decision Making
baasie
3
430
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
Skip the Path - Find Your Career Trail
mkilby
1
160
It's Worth the Effort
3n
188
29k
How STYLIGHT went responsive
nonsquared
100
6.2k
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
A Tale of Four Properties
chriscoyier
163
24k
Test your architecture with Archunit
thirion
1
2.3k
Are puppies a ranking factor?
jonoalderson
1
3.7k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
880
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
Git: the NoSQL Database
bkeepers
PRO
432
67k
Transcript
リファクタリング 既存のコードを安全に改善する 意図が伝わるコードの書き方
リファクタリングとは? • プログラムの振る舞い(仕様)を変えずに内部品質を向上させる作業 • 内部品質: 保守性、可読性等 • バグ修正ではない(リファクタリングとバグ修正は別で行う) • 実現方法:
カプセル化、関数化、名前の変更等
ロジックを関数化する目的とは? 1. 再利用性を高める(同じ処理を繰り返し書かない) 2. 可読性を上げる(行数を減らす) 3. 意図を明確にする(何をやっているかを読み手に伝える)
サンプルコード(リファクタリング前) ※ if文の条件が長くなると単純に読み辛く、理解しづらいという問題も つまりどういうことだってばよ?
サンプルコード(リファクタリング後) 曜日判定ロジックを 別関数に抽出 週末は割増料金になることをより明確に表現 ※ ユニットテストのしやすさも向上
関数命名のセオリー 「実装」と「意図」を分離する つまり「どうやって処理を行っているか」ではなく 「何をしているか」に着目して命名する × isDayOfWeekZeroOne() ◦ isWeekend()