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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
200
Upgrading Legacy to the Latest PHP Version
afilina
1
220
Better Code Design in PHP
afilina
0
320
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
220
Better Code Design in PHP
afilina
1
470
Better Code Design in PHP
afilina
0
640
Adding Tests to Untestable Legacy Code
afilina
0
430
Upgrading Legacy to the Latest PHP Version
afilina
0
440
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
350
Other Decks in Programming
See All in Programming
2年かけて Deno に DOMMatrix を実装した話 / How I implemented DOMMatrix in Deno over two years
petamoriken
0
180
AIが無かった頃の素敵な出会いの話
codmoninc
1
260
そこに3びきプロダクトがいるじゃろう——生成AI時代における“価値が届かない理由”の構造
kosuket
0
220
使いながら育てる Claude Code — 開発フローの1コマンド化 × 繰り返し指摘の自動仕組み化
shiki_kakaku
0
810
ビデオ通話が繋がる0.2秒で何が起きているのか
supurazako
2
150
AI時代、エンジニアはどう育つのか -未経験エンジニアの成長を間近で見て考えたこと-
thasu0123
0
180
AI時代のPHPer生存戦略 ~「言語、もうなんでもよくない?」に本気で向き合う~
vivion
0
190
FDEが実現するAI駆動経営の現在地
gonta
2
230
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
100
【やさしく解説 設計編・中級 #1】一つの車に、運転手は一人 ~ある倉庫システムの事例から~
panda728
PRO
0
200
광주소프트웨어마이스터고등학교 DevFest 특강 - 바이브 코딩 시대에서 주니어 개발자로 살아남는 방법
utilforever
1
150
音楽のための関数型プログラミング言語mimiumにおける多段階計算の活用
tomoyanonymous
1
360
Featured
See All Featured
HDC tutorial
michielstock
2
760
Everyday Curiosity
cassininazir
0
260
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
Automating Front-end Workflow
addyosmani
1370
210k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
220
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
330
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
530
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.9k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
350
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
630
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