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
0
260
Cyclomatic Complexity
Don’t write unnecessary tests anymore. Use a simple, scientific approach.
Anna Filina
October 08, 2016
Tweet
Share
More Decks by Anna Filina
See All by Anna Filina
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
100
Better Code Design in PHP
afilina
0
270
Better Code Design in PHP
afilina
0
480
Adding Tests to Untestable Legacy Code
afilina
0
320
Upgrading Legacy to the Latest PHP Version
afilina
0
320
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
210
Better Code Design in PHP
afilina
1
680
Effortless Software Development
afilina
1
290
Writing Testable Symfony Apps
afilina
0
380
Other Decks in Programming
See All in Programming
WebDriver BiDiとは何なのか
yotahada3
1
140
Honoをフロントエンドで使う 3つのやり方
yusukebe
7
3.2k
動作確認やテストで漏れがちな観点3選
starfish719
6
1k
ソフトウェアエンジニアの成長
masuda220
PRO
10
1.1k
ASP. NET CoreにおけるWebAPIの最新情報
tomokusaba
0
370
AIの力でお手軽Chrome拡張機能作り
taiseiue
0
170
Unity Android XR入門
sakutama_11
0
150
SwiftUI Viewの責務分離
elmetal
PRO
1
230
DevinとCursorから学ぶAIエージェントメモリーの設計とMoatの考え方
itarutomy
1
680
2024年のkintone API振り返りと2025年 / kintone API look back in 2024
tasshi
0
220
ISUCON14公式反省会LT: 社内ISUCONの話
astj
PRO
0
190
ARA Ansible for the teams
kksat
0
150
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
461
33k
Become a Pro
speakerdeck
PRO
26
5.1k
Site-Speed That Sticks
csswizardry
4
380
The World Runs on Bad Software
bkeepers
PRO
67
11k
Designing on Purpose - Digital PM Summit 2013
jponch
117
7.1k
A Philosophy of Restraint
colly
203
16k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
30
4.6k
Music & Morning Musume
bryan
46
6.3k
Into the Great Unknown - MozCon
thekraken
35
1.6k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
174
51k
Thoughts on Productivity
jonyablonski
69
4.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