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
PRO
October 08, 2016
Programming
0
260
Cyclomatic Complexity
Don’t write unnecessary tests anymore. Use a simple, scientific approach.
Anna Filina
PRO
October 08, 2016
Tweet
Share
More Decks by Anna Filina
See All by Anna Filina
Better Code Design in PHP
afilina
PRO
0
400
Adding Tests to Untestable Legacy Code
afilina
PRO
0
270
Upgrading Legacy to the Latest PHP Version
afilina
PRO
0
280
Semi-Automated Refactoring and Upgrades with Rector
afilina
PRO
0
150
Better Code Design in PHP
afilina
PRO
1
630
Effortless Software Development
afilina
PRO
1
270
Writing Testable Symfony Apps
afilina
PRO
0
350
Upgrading Legacy to the Latest PHP Version
afilina
PRO
0
330
Avoid Costly Framework Upgrades
afilina
PRO
2
1.7k
Other Decks in Programming
See All in Programming
Identifying User Idenity
moro
4
5.1k
Scan with Decoupled Look-back and Onesweep Radix Sort
shocker_0x15
0
160
いかにして不足・不整合なくデータ移行したか
tjmtmmnk
1
1k
Go言語でターミナルフレンドリーなAIコマンド、afaを作った/fukuokago20_afa
monochromegane
2
130
外部システム連携先が10を超えるシステムでのアーキテクチャ設計・実装事例
kiwasaki
1
140
Universal Linksの実装方法と陥りがちな罠
kaitokudou
1
210
CSC305 Lecture 13
javiergs
PRO
0
120
rtcamp 10 (vk-illuminati)
yumcyawiz
1
220
Mercari AI/LLM Hackathon TeamBの発表資料
imaikosuke
0
200
弊社の「意識チョット低いアーキテクチャ」10選
texmeijin
0
1.2k
Prompt Engineering for Developers @ AWS Community Day Adria 2024
slobodan
0
110
Modern Angular: Renovation for Your Applications
manfredsteyer
PRO
0
130
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
A designer walks into a library…
pauljervisheath
202
24k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Learning to Love Humans: Emotional Interface Design
aarron
272
40k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
504
140k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
32
1.7k
Into the Great Unknown - MozCon
thekraken
31
1.4k
Speed Design
sergeychernyshev
24
560
RailsConf 2023
tenderlove
29
870
Bash Introduction
62gerente
608
210k
Keith and Marios Guide to Fast Websites
keithpitt
408
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