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
300
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
More Decks by Anna Filina
See All by Anna Filina
Surviving a Symfony Upgrade
afilina
1
190
Upgrading Legacy to the Latest PHP Version
afilina
1
210
Better Code Design in PHP
afilina
0
320
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
210
Better Code Design in PHP
afilina
1
470
Better Code Design in PHP
afilina
0
630
Adding Tests to Untestable Legacy Code
afilina
0
420
Upgrading Legacy to the Latest PHP Version
afilina
0
440
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
340
Other Decks in Programming
See All in Programming
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
Lessons from Spec-Driven Development
simas
PRO
0
240
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
230
トークンをケチるな、設計しろ:GitHub Copilotを賢く使うコンテキスト戦略
ochtum
0
270
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
420
AIキャラアプリkaiwaの低遅延音声通話基盤をどう作ったか - AWS Gravitonで支える低遅延・低コストAI Agent基盤
mogamit
0
150
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
260
任せる範囲はこう広がった / How the Scope of AI Delegation Has Expanded
nrslib
1
220
A2UI という光を覗いてみる
satohjohn
1
170
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
210
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
150
Creating Composable Callables in Contemporary C++
rollbear
0
180
Featured
See All Featured
The Mindset for Success: Future Career Progression
greggifford
PRO
0
370
We Are The Robots
honzajavorek
0
260
Navigating Weather and Climate Data
rabernat
0
260
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
630
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
A Modern Web Designer's Workflow
chriscoyier
698
190k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
240
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.3k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
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