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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Anna Filina
October 08, 2016
Programming
0
280
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
Surviving a Symfony Upgrade
afilina
0
120
Upgrading Legacy to the Latest PHP Version
afilina
1
160
Better Code Design in PHP
afilina
0
280
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
180
Better Code Design in PHP
afilina
1
440
Better Code Design in PHP
afilina
0
600
Adding Tests to Untestable Legacy Code
afilina
0
380
Upgrading Legacy to the Latest PHP Version
afilina
0
400
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
300
Other Decks in Programming
See All in Programming
IFSによる形状設計/デモシーンの魅力 @ 慶應大学SFC
gam0022
1
300
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
550
Spinner 軸ズレ現象を調べたらレンダリング深淵に飲まれた #レバテックMeetup
bengo4com
1
230
AI時代のキャリアプラン「技術の引力」からの脱出と「問い」へのいざない / tech-gravity
minodriven
20
7k
Patterns of Patterns
denyspoltorak
0
1.4k
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
190
Apache Iceberg V3 and migration to V3
tomtanaka
0
150
Basic Architectures
denyspoltorak
0
660
AI巻き込み型コードレビューのススメ
nealle
1
150
AIによる高速開発をどう制御するか? ガードレール設置で開発速度と品質を両立させたチームの事例
tonkotsuboy_com
7
2.1k
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
1
1.3k
AI & Enginnering
codelynx
0
110
Featured
See All Featured
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.3k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
320
Believing is Seeing
oripsolob
1
53
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
130
The Cost Of JavaScript in 2023
addyosmani
55
9.5k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
55
Test your architecture with Archunit
thirion
1
2.1k
Designing Powerful Visuals for Engaging Learning
tmiket
0
230
The Language of Interfaces
destraynor
162
26k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
0
1.9k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
72
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