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
290
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
180
Upgrading Legacy to the Latest PHP Version
afilina
1
200
Better Code Design in PHP
afilina
0
310
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
210
Better Code Design in PHP
afilina
1
460
Better Code Design in PHP
afilina
0
630
Adding Tests to Untestable Legacy Code
afilina
0
410
Upgrading Legacy to the Latest PHP Version
afilina
0
430
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
340
Other Decks in Programming
See All in Programming
今さら聞けないCancellationToken
htkym
0
220
CSC307 Lecture 17
javiergs
PRO
0
320
AIエージェントと協働するCLI開発 — BunとOpenClawで学んだこと
yoshikouki
1
240
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
1.7k
oxlintはeslint/typescript-eslintを置き換えられるのか
shomafujita
2
320
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
0
170
エージェンティックRAGにAWSで入門しよう!
har1101
8
1.2k
AIチームを指揮するOSS「TAKT」活用術 / How to Use “TAKT,” an OSS Tool for Orchestrating AI Teams
nrslib
6
840
Claspは野良GASの夢をみるか
takter00
0
170
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
300
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
1
620
OSもどきOS
arkw
0
460
Featured
See All Featured
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
220
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
200
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
360
Navigating Team Friction
lara
192
16k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
65
55k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Typedesign – Prime Four
hannesfritz
42
3.1k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
170
Ruling the World: When Life Gets Gamed
codingconduct
0
250
The untapped power of vector embeddings
frankvandijk
2
1.7k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
First, design no harm
axbom
PRO
2
1.2k
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