Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Working With Legacy Code - iOS TDD Workshop
Search
Maciej Oczko
July 05, 2014
Programming
0
170
Working With Legacy Code - iOS TDD Workshop
Talk given on iOS TDD Workshop in Berlin.
Maciej Oczko
July 05, 2014
Tweet
Share
More Decks by Maciej Oczko
See All by Maciej Oczko
Dependency Injection on iOS
maciejoczko
1
130
Working with Legacy Code (Łódź)
maciejoczko
0
54
iOS TDD Workshop (Gdańsk)
maciejoczko
1
81
UICollectionView Basics and Flow Layout
maciejoczko
0
240
UICollectionView Introduction
maciejoczko
0
62
Depenedency Injection in iOS
maciejoczko
0
70
Other Decks in Programming
See All in Programming
生成AIを利用するだけでなく、投資できる組織へ
pospome
2
360
從冷知識到漏洞,你不懂的 Web,駭客懂 - Huli @ WebConf Taiwan 2025
aszx87410
2
2.8k
Rubyで鍛える仕組み化プロヂュース力
muryoimpl
0
140
著者と進める!『AIと個人開発したくなったらまずCursorで要件定義だ!』
yasunacoffee
0
150
JETLS.jl ─ A New Language Server for Julia
abap34
1
420
実は歴史的なアップデートだと思う AWS Interconnect - multicloud
maroon1st
0
220
AIの誤りが許されない業務システムにおいて“信頼されるAI” を目指す / building-trusted-ai-systems
yuya4
6
3.8k
公共交通オープンデータ × モバイルUX 複雑な運行情報を 『直感』に変換する技術
tinykitten
PRO
0
120
LLMで複雑な検索条件アセットから脱却する!! 生成的検索インタフェースの設計論
po3rin
4
850
宅宅自以為的浪漫:跟 AI 一起為自己辦的研討會寫一個售票系統
eddie
0
510
脳の「省エネモード」をデバッグする ~System 1(直感)と System 2(論理)の切り替え~
panda728
PRO
0
100
Socio-Technical Evolution: Growing an Architecture and Its Organization for Fast Flow
cer
PRO
0
370
Featured
See All Featured
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
60
Stop Working from a Prison Cell
hatefulcrawdad
273
21k
From π to Pie charts
rasagy
0
86
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
3.4k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
190
We Have a Design System, Now What?
morganepeng
54
7.9k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
0
87
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.1k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Code Reviewing Like a Champion
maltzj
527
40k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
160
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.6k
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