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
Cyclomatic Complexity
Search
Anna Filina
October 08, 2016
Programming
0
280
Cyclomatic Complexity
Don’t write unnecessary tests anymore. Use a simple, scientific approach.
Anna Filina
October 08, 2016
Tweet
Share
More Decks by Anna Filina
See All by Anna Filina
Surviving a Symfony Upgrade
afilina
0
90
Upgrading Legacy to the Latest PHP Version
afilina
1
150
Better Code Design in PHP
afilina
0
270
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
170
Better Code Design in PHP
afilina
1
430
Better Code Design in PHP
afilina
0
590
Adding Tests to Untestable Legacy Code
afilina
0
380
Upgrading Legacy to the Latest PHP Version
afilina
0
390
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
300
Other Decks in Programming
See All in Programming
クラウドに依存しないS3を使った開発術
simesaba80
0
200
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
7
2.4k
Findy AI+の開発、運用におけるMCP活用事例
starfish719
0
1.9k
AtCoder Conference 2025「LLM時代のAHC」
imjk
2
610
JETLS.jl ─ A New Language Server for Julia
abap34
2
470
脳の「省エネモード」をデバッグする ~System 1(直感)と System 2(論理)の切り替え~
panda728
PRO
0
130
TerraformとStrands AgentsでAmazon Bedrock AgentCoreのSSO認証付きエージェントを量産しよう!
neruneruo
4
2.1k
ThorVG Viewer In VS Code
nors
0
460
DevFest Android in Korea 2025 - 개발자 커뮤니티를 통해 얻는 가치
wisemuji
0
180
AIエンジニアリングのご紹介 / Introduction to AI Engineering
rkaga
8
3.5k
認証・認可の基本を学ぼう後編
kouyuume
0
260
チームをチームにするEM
hitode909
0
420
Featured
See All Featured
Done Done
chrislema
186
16k
How to Think Like a Performance Engineer
csswizardry
28
2.4k
Git: the NoSQL Database
bkeepers
PRO
432
66k
Context Engineering - Making Every Token Count
addyosmani
9
570
Faster Mobile Websites
deanohume
310
31k
The Cult of Friendly URLs
andyhume
79
6.7k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
75
Unsuck your backbone
ammeep
671
58k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
115
100k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
Ethics towards AI in product and experience design
skipperchong
1
150
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
61
47k
Transcript
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