$30 off During Our Annual Pro Sale. View Details »
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 一起為自己辦的研討會寫一個售票系統
eddie
0
500
C-Shared Buildで突破するAI Agent バックテストの壁
po3rin
0
380
リリース時」テストから「デイリー実行」へ!開発マネージャが取り組んだ、レガシー自動テストのモダン化戦略
goataka
0
120
【CA.ai #3】Google ADKを活用したAI Agent開発と運用知見
harappa80
0
300
dnx で実行できるコマンド、作ってみました
tomohisa
0
140
WebRTC と Rust と8K 60fps
tnoho
2
1.9k
AIエージェントを活かすPM術 AI駆動開発の現場から
gyuta
0
370
開発に寄りそう自動テストの実現
goyoki
1
810
【CA.ai #3】ワークフローから見直すAIエージェント — 必要な場面と“選ばない”判断
satoaoaka
0
240
DevFest Android in Korea 2025 - 개발자 커뮤니티를 통해 얻는 가치
wisemuji
0
110
俺流レスポンシブコーディング 2025
tak_dcxi
14
8.5k
AIエンジニアリングのご紹介 / Introduction to AI Engineering
rkaga
5
2k
Featured
See All Featured
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
390
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.6k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.8k
Into the Great Unknown - MozCon
thekraken
40
2.2k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
36
6.2k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Being A Developer After 40
akosma
91
590k
RailsConf 2023
tenderlove
30
1.3k
The Pragmatic Product Professional
lauravandoore
37
7.1k
Git: the NoSQL Database
bkeepers
PRO
432
66k
How STYLIGHT went responsive
nonsquared
100
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