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
Working With Legacy Code - iOS TDD Workshop
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Maciej Oczko
July 05, 2014
Programming
170
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Working With Legacy Code - iOS TDD Workshop
Talk given on iOS TDD Workshop in Berlin.
Maciej Oczko
July 05, 2014
More Decks by Maciej Oczko
See All by Maciej Oczko
Dependency Injection on iOS
maciejoczko
1
130
Working with Legacy Code (Łódź)
maciejoczko
0
59
iOS TDD Workshop (Gdańsk)
maciejoczko
1
85
UICollectionView Basics and Flow Layout
maciejoczko
0
240
UICollectionView Introduction
maciejoczko
0
63
Depenedency Injection in iOS
maciejoczko
0
73
Other Decks in Programming
See All in Programming
自動化したのに回らない テスト運用の壁―AI時代の品質責任と生産性
mfunaki
0
540
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
570
Discordを用いたラボオートメーション関連情報収集の自動化
noguhiro2002
0
460
夏だ!祭りだ!祭りとはドメインモデリングでは?
ryugen04
0
450
tsc.rip を支える技術 / Kyoto.なんか #8
susisu
0
3.9k
ハーネス設計入門 〜プロンプト、コンテキストの次〜
kinopeee
41
26k
Hono + Inertia + React で LP を構築した話
oukayuka
2
190
Hello, Hiroshima Geospatial Data! — Exploring DoboX with Python
ra0kley
0
120
ソフトウェアラスタライザ
fadis
1
730
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
800
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
7.9k
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
510
Featured
See All Featured
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
880
GraphQLとの向き合い方2022年版
quramy
50
15k
Un-Boring Meetings
codingconduct
0
400
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
630
Utilizing Notion as your number one productivity tool
mfonobong
4
560
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Visualization
eitanlees
152
17k
エンジニアに許された特別な時間の終わり
watany
108
250k
We Have a Design System, Now What?
morganepeng
55
8.3k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
Transcript
Working With Code Legacy @maciejoczko #tddberlin
Code is you didn’t write this morning (yet). What is
LegacyCode? Code is legacy code as soon as it's written. @maciejoczko #tddberlin
Code is legacy code as soon as it's written. Michael
Feathers, Working Effectively with Legacy Code What is LegacyCode? Code is you didn’t write this morning (yet). @maciejoczko #tddberlin
Code without tests* Inherited code Poorly designed code Too complicated
code Illegible code *Michael Feathers What is LegacyCode? Code is legacy code as soon as it's written. Michael Feathers, Working Effectively with Legacy Code @maciejoczko #tddberlin
Testing scenario #1 Task @maciejoczko #tddberlin
How to approach it? Identify change points Find an inflection
point Cover the Make changes Refactor the covered code inflection point @maciejoczko #tddberlin
B A D C E inflection point @maciejoczko #tddberlin
Violation of Single Responsibility Principle Violation of Open-Closed Principle inflection
point @maciejoczko #tddberlin
inflection point Covering external dependencies Break @maciejoczko #tddberlin
inflection point Covering external dependencies internal dependencies Break Break @maciejoczko
#tddberlin
inflection point Covering external dependencies internal dependencies Write tests Break
Break @maciejoczko #tddberlin
inflection point Covering external dependencies internal dependencies Write tests Break
Break @maciejoczko #tddberlin
- (NSUInteger)calculatePrice { ... StockAnalyzer *analyzer = [[StockAnalyzer alloc] init];
... } - (id)initWithAnalyzer:(id <AnalyzerProtocol>)analyzer { self = [super init]; if (self) { _analyzer = analyzer; } return self; } external dependencies Break @maciejoczko #tddberlin
external dependencies Break internal dependencies Write tests Break inflection point
Covering @maciejoczko #tddberlin
- (CGSize)calculateSize { ... UIScreen *screen = [UIScreen mainScreen]; ...
} - (CGSize)calculateSize { ... UIScreen *screen = [self screen]; ... } - (UIScreen *)screen { return [UIScreen mainScreen]; } Break internal dependencies @maciejoczko #tddberlin
external dependencies Break internal dependencies Write tests Break inflection point
Covering @maciejoczko #tddberlin
Write tests @maciejoczko #tddberlin
Make changes @maciejoczko #tddberlin
Testing scenario #2 Task @maciejoczko #tddberlin
When to Refactor? Too wide class responsibility Duplicated code Not
readable code Too many method arguments (more than 2) Method has more than 20 lines Class has more than 150-200 lines @maciejoczko #tddberlin
Keep in mind Composition over inheritance Avoid singletons Isolate dependencies
Inject dependencies @maciejoczko #tddberlin
Thanks! @maciejoczko #tddberlin