Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
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
[JA] Domain Modeling with Vanilla Rails: 「操作」から再考するRailsの設計論
yasaichi
4
1.8k
ActionController meets Protocol Buffers
sorah
1
780
AI時代のFlutter品質設計 — アプリ品質を守るQuality Layers
omatty198
0
360
baseline으로 마이그레이션, 리팩토링 안전하게 맡기기
fornewid
1
910
Inertia Rails: The One-Person Framework with React & Friends
skryukov
0
380
Kotlinize Is Not Just Converting to Kotlin
chigichan24
1
220
Web3Dライブラリを作ってVue Custom Rendererの仕組みを理解しよう / lets learn vue custom renderer by making 3d library
drumath2237
1
120
Web Framework Benchmark Battle 2026, Any%
a_matsuda
3
3.1k
SODA - FACT BOOK(EN)
sodainc
1
210
Railsのためのパスキー実践入門 〜マルチテナントSaaSでの意思決定〜
utakaha
4
3.4k
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
200
Modernizing iOS Apps
seyfoyun
0
150
Featured
See All Featured
Become a Pro
speakerdeck
PRO
31
6.4k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1.1k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.8k
Deep Space Network (abreviated)
tonyrice
0
410
Odyssey Design
rkendrick25
PRO
2
930
Reality Check: Gamification 10 Years Later
codingconduct
0
2.4k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
A Modern Web Designer's Workflow
chriscoyier
699
190k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
290
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
590
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
70
68k
Transcript
リファクタリング 既存のコードを安全に改善する 意図が伝わるコードの書き方
リファクタリングとは? • プログラムの振る舞い(仕様)を変えずに内部品質を向上させる作業 • 内部品質: 保守性、可読性等 • バグ修正ではない(リファクタリングとバグ修正は別で行う) • 実現方法:
カプセル化、関数化、名前の変更等
ロジックを関数化する目的とは? 1. 再利用性を高める(同じ処理を繰り返し書かない) 2. 可読性を上げる(行数を減らす) 3. 意図を明確にする(何をやっているかを読み手に伝える)
サンプルコード(リファクタリング前) ※ if文の条件が長くなると単純に読み辛く、理解しづらいという問題も つまりどういうことだってばよ?
サンプルコード(リファクタリング後) 曜日判定ロジックを 別関数に抽出 週末は割増料金になることをより明確に表現 ※ ユニットテストのしやすさも向上
関数命名のセオリー 「実装」と「意図」を分離する つまり「どうやって処理を行っているか」ではなく 「何をしているか」に着目して命名する × isDayOfWeekZeroOne() ◦ isWeekend()