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
Writing testable code
Search
Rodrigo Boniatti
November 30, 2019
Programming
0
51
Writing testable code
Rodrigo Boniatti
November 30, 2019
Tweet
Share
More Decks by Rodrigo Boniatti
See All by Rodrigo Boniatti
The pillars of integration
boniatti
0
62
Designing and building software with Ruby on Rails
boniatti
0
44
Mobile development with React Native
boniatti
1
3.5k
Other Decks in Programming
See All in Programming
各クラウドサービスにおける.NETの対応と見解
ymd65536
0
250
AHC041解説
terryu16
0
400
最近のVS Codeで気になるニュース 2025/01
74th
1
100
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
6
1.4k
“あなた” の開発を支援する AI エージェント Bedrock Engineer / introducing-bedrock-engineer
gawa
4
250
ISUCON14感想戦で85万点まで頑張ってみた
ponyo877
1
590
Package Traits
ikesyo
1
210
Beyond ORM
77web
11
1.6k
PHPで学ぶプログラミングの教訓 / Lessons in Programming Learned through PHP
nrslib
4
1.1k
ドメインイベント増えすぎ問題
h0r15h0
2
570
オニオンアーキテクチャを使って、 Unityと.NETでコードを共有する
soi013
0
370
.NETでOBS Studio操作してみたけど…… / Operating OBS Studio by .NET
skasweb
0
120
Featured
See All Featured
Building Your Own Lightsaber
phodgson
104
6.2k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Faster Mobile Websites
deanohume
305
30k
Rails Girls Zürich Keynote
gr2m
94
13k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Code Reviewing Like a Champion
maltzj
521
39k
Optimizing for Happiness
mojombo
376
70k
4 Signs Your Business is Dying
shpigford
182
22k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.8k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.2k
Designing for Performance
lara
604
68k
Transcript
Writing testable code
Rodrigo Boniatti Developer at Codeminer 42 @boniattirodrigo rodrigoboniatti.com
Conditionals
None
Smell
None
None
Refactored
None
None
Conditionals • Smell: • High cyclomatic complexity score; • How
to solve? • Replace Conditional with Polymorphism;
Global state
Smell
None
Refactored
None
Global state • Smell: • Coupling; • How to solve?
• Dependency injection;
Life cycle events
Smell
None
Refactored
None
Life cycle events • Smell: • Hide code behavior; •
No execution order; • How to solve? • Single flow;
Principles of testing
Principles of testing • Test in isolation; • A lot
of setup == smell; • Hard to test == smell;
Questions?
Thank you Code examples: https://github.com/boniattirodrigo/writing-testable-code