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
310
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
210
Upgrading Legacy to the Latest PHP Version
afilina
1
230
Better Code Design in PHP
afilina
0
330
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
220
Better Code Design in PHP
afilina
1
490
Better Code Design in PHP
afilina
0
650
Adding Tests to Untestable Legacy Code
afilina
0
440
Upgrading Legacy to the Latest PHP Version
afilina
0
450
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
360
Other Decks in Programming
See All in Programming
異なる設計思想のフレームワークを経験して得た学び
amekuhideki
2
1.5k
Swift愛好会100回記念 第1回を振り返る
jollyjoester
0
100
レビュー履歴をAIに食わせて、 Compose移行を加速するs
shihochan
0
260
My Marp Sample
sinoue0108
0
140
Swift愛好会と私(ウホーイ) / Swift Fan Club and Uhooi
uhooi
0
120
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
620
【QA Test Talk Vol.8】AI-DLC による Whole Team Approach の加速
pkshadeck
PRO
0
280
Claude Codeを組織的に動かして月400PRを実現した話
happy_ryo
0
250
Seeing Through Serverless: Observability for AWS Lambda with ADOT and CloudWatch Application Signals
seike460
PRO
1
110
【DroidKaigi 2026】「アクセシビリティを利用するとき、 アクセシビリティもまたこちらを利用している」 〜マルウェアによる攻撃と防衛について〜
halunoyo
0
300
新人はどこまで自力でやり、どこからAIに頼るべきか/エンジニア育成に向き合う_先輩たちの悩みと知見共有会
toppan_digital_dev
1
540
承認済みなのに差戻しできてしまうバグ、型で潰せます
shinchit
0
130
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Designing for Performance
lara
611
70k
Documentation Writing (for coders)
carmenintech
77
5.5k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
640
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
490
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.8k
Utilizing Notion as your number one productivity tool
mfonobong
4
570
Skip the Path - Find Your Career Trail
mkilby
1
220
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
First, design no harm
axbom
PRO
2
1.3k
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