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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Anna Filina
October 08, 2016
Programming
290
0
Share
Cyclomatic Complexity
Don’t write unnecessary tests anymore. Use a simple, scientific approach.
Anna Filina
October 08, 2016
More Decks by Anna Filina
See All by Anna Filina
Surviving a Symfony Upgrade
afilina
1
160
Upgrading Legacy to the Latest PHP Version
afilina
1
180
Better Code Design in PHP
afilina
0
290
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
190
Better Code Design in PHP
afilina
1
450
Better Code Design in PHP
afilina
0
610
Adding Tests to Untestable Legacy Code
afilina
0
390
Upgrading Legacy to the Latest PHP Version
afilina
0
410
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
320
Other Decks in Programming
See All in Programming
Feature Toggle は捨てやすく使おう
gennei
0
400
おれのAgentic Coding 2026/03
tsukasagr
1
120
ネイティブアプリとWebフロントエンドのAPI通信ラッパーにおける共通化の勘所
suguruooki
0
230
Codex CLI でつくる、Issue から merge までの開発フロー
amata1219
0
280
実践ハーネスエンジニアリング #MOSHTech
kajitack
7
5.4k
Linux Kernelの1文字のミスで 権限昇格ができた話
rqda
0
2.2k
テレメトリーシグナルが導くパフォーマンス最適化 / Performance Optimization Driven by Telemetry Signals
seike460
PRO
2
200
AI時代のシステム設計:ドメインモデルで変更しやすさを守る設計戦略
masuda220
PRO
6
1.2k
ファインチューニングせずメインコンペを解く方法
pokutuna
0
250
L’IA au service des devs : Anatomie d'un assistant de Code Review
toham
0
180
一度始めたらやめられない開発効率向上術 / Findy あなたのdotfilesを教えて!
k0kubun
3
2.7k
PHPのバージョンアップ時にも役立ったAST(2026年版)
matsuo_atsushi
0
280
Featured
See All Featured
Design in an AI World
tapps
0
190
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Unsuck your backbone
ammeep
672
58k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
120
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
110
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
500
Being A Developer After 40
akosma
91
590k
From π to Pie charts
rasagy
0
160
Navigating Team Friction
lara
192
16k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
990
Code Review Best Practice
trishagee
74
20k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
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