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
270
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
Upgrading Legacy to the Latest PHP Version
afilina
1
120
Better Code Design in PHP
afilina
0
250
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
160
Better Code Design in PHP
afilina
1
420
Better Code Design in PHP
afilina
0
560
Adding Tests to Untestable Legacy Code
afilina
0
360
Upgrading Legacy to the Latest PHP Version
afilina
0
380
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
280
Better Code Design in PHP
afilina
1
740
Other Decks in Programming
See All in Programming
概念モデル→論理モデルで気をつけていること
sunnyone
2
230
Amazon RDS 向けに提供されている MCP Server と仕組みを調べてみた/jawsug-okayama-2025-aurora-mcp
takahashiikki
1
110
Azure SRE Agentで運用は楽になるのか?
kkamegawa
0
2.3k
testingを眺める
matumoto
1
140
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
380
AI時代のUIはどこへ行く?
yusukebe
18
8.9k
ファインディ株式会社におけるMCP活用とサービス開発
starfish719
0
1.6k
Putting The Genie in the Bottle - A Crash Course on running LLMs on Android
iurysza
0
140
[FEConf 2025] 모노레포 절망편, 14개 레포로 부활하기까지 걸린 1년
mmmaxkim
0
1.6k
Tool Catalog Agent for Bedrock AgentCore Gateway
licux
6
2.5k
print("Hello, World")
eddie
2
530
250830 IaCの選定~AWS SAMのLambdaをECSに乗り換えたときの備忘録~
east_takumi
0
390
Featured
See All Featured
Making Projects Easy
brettharned
117
6.4k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.5k
We Have a Design System, Now What?
morganepeng
53
7.8k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
Into the Great Unknown - MozCon
thekraken
40
2k
How to Think Like a Performance Engineer
csswizardry
26
1.9k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
51
5.6k
Rebuilding a faster, lazier Slack
samanthasiow
83
9.2k
Making the Leap to Tech Lead
cromwellryan
135
9.5k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
13k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
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