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
Cyclomatic Complexity
Search
Anna Filina
October 08, 2016
Programming
330
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Cyclomatic Complexity
Don’t write unnecessary tests anymore. Use a simple, scientific approach.
Anna Filina
October 08, 2016
Transcript
14 slides
foolab.ca | @foolabca Cyclomatic Complexity Bulgaria PHP, Sofia - October
8, 2016
Execution Paths public function getShipping() { if ($this->subtotal >= 40)
{ return 0; } return $this->standardShipping; } 2
Execution Paths public function getShipping() { if ($this->subtotal >= 40)
{ return 0; } return $this->standardShipping; } 3 Path 1 Path 2
Decision Branches 4 start product loop free shipping? end
Decision Branches 5 start product loop free shipping? end
Cyclomatic complexity = edges − nodes + 2 * connected
components
Decision Branches 7 start product loop free shipping? end ◦
Edges ◦ Nodes ◦ Connected components.
Decision Branches 8 start product loop free shipping? end ◦
Edges ◦ Nodes ◦ Connected components.
Decision Branches 9 start product loop free shipping? end ◦
Edges ◦ Nodes ◦ Connected components.
Cyclomatic complexity = 9 − 8 + 2 * 1
= 3
Zero Times foreach ($products as $product) { $total = $product->price
* $product->quantity; } $tax = $total * ... 11
Multiple Times $total = 0; foreach ($products as $product) {
$total = $product->price * $product->quantity; } $tax = $total * ... 12
Multiple Times $total = 0; foreach ($products as $product) {
$total += $product->price * $product->quantity; } $tax = $total * ... 13
@afilina afilina.com
More Decks by Anna Filina
See All by Anna Filina
Surviving a Symfony Upgrade
afilina
1
220
Upgrading Legacy to the Latest PHP Version
afilina
1
250
Better Code Design in PHP
afilina
0
340
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
250
Better Code Design in PHP
afilina
1
500
Better Code Design in PHP
afilina
0
680
Adding Tests to Untestable Legacy Code
afilina
0
460
Upgrading Legacy to the Latest PHP Version
afilina
0
470
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
370
Other Decks in Programming
See All in Programming
Spec-driven Development with AI
simas
PRO
0
2.3k
Stage 3でも仕様は変わる。アプリケーション開発者のためのTC39プロセスの読み方
bicstone
1
930
高橋メソッドでCVE解説シリーズ 〜CVE-2026-112816〜
hakkadaikon
0
280
AIが実装を担う時代の「技術設計」と「チームマネジメント」
kamina_zzz
2
470
エージェントの管理もエージェントに – herdr-core と自作バックログで作る司令塔 –
nearme_tech
PRO
2
160
TS 7.0 で baseUrl が使えなくなった今、パスエイリアスをどうするか
bicstone
2
850
SONY CISC-NEWS NWS-1750 + NWB-225 ハードウェアメンテとフレームバッファカラー対応 / KOF2026
tsutsui
0
150
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
220
[DroidKnights 2026] Workflow AX: From Auto-Documented Policies to E2E Testing
raeminkang
0
610
そのデザイントークン、Flutterでも同じ見た目になりますか?
nakamizu
0
490
SODA - FACT BOOK(JP)
sodainc
1
40k
眠らない開発チームの作り方
biwakonbu
0
170
Featured
See All Featured
The SEO Collaboration Effect
kristinabergwall1
1
630
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
490
brightonSEO & MeasureFest 2025 - Winning Strategies for Black Friday CRO & PPC - Christian Goodrich
cargoodrich
3
910
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
480
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
From π to Pie charts
rasagy
1
460
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
First, design no harm
axbom
PRO
2
1.4k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
620
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
470
4 Signs Your Business is Dying
shpigford
187
23k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
490