SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Downloaden Sie, um offline zu lesen
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
ABC Size
Dave Doolin
A code complexity metric, easy as 1-2-3.
April 21, 2024
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
ABC Size
Assignment, Branch, Condition
Definition of ABC Size:
√
A2 +B2 +C2
A: Assignment
B: Branch (method calls)
C: Conditional
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Rubocop
ftw
For demonstration purposes, we’ll set Metrics/AbcSize to 0.
1 # Just enough rubocop for demonstration
2
3 AllCops:
4 NewCops: enable
5
6 Style/FrozenStringLiteralComment:
7 Enabled: false
8
9 # Set to 0 to force output
10 Metrics/AbcSize:
11 Max: 0
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Example
Let’s count!
1 # Demonstration of ABC Size
2 class AbcSize
3 def demonstrate
4 a = 'foo'
5 b = 'bar'
6 c = rand(2).even? ? 'baz' : 'quux'
7 a + b + c # a.+ b.+ c
8 end
9 end
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Example
Let’s count!
1 # Demonstration of ABC Size
2 class AbcSize
3 def demonstrate
4 a = 'foo'
5 b = 'bar'
6 c = rand(2).even? ? 'baz' : 'quux'
7 a + b + c # a.+ b.+ c
8 end
9 end
Assignments:
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Example
Let’s count!
1 # Demonstration of ABC Size
2 class AbcSize
3 def demonstrate
4 a = 'foo'
5 b = 'bar'
6 c = rand(2).even? ? 'baz' : 'quux'
7 a + b + c # a.+ b.+ c
8 end
9 end
Assignments: 3
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Example
Let’s count!
1 # Demonstration of ABC Size
2 class AbcSize
3 def demonstrate
4 a = 'foo'
5 b = 'bar'
6 c = rand(2).even? ? 'baz' : 'quux'
7 a + b + c # a.+ b.+ c
8 end
9 end
Assignments: 3
Branches:
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Example
Let’s count!
1 # Demonstration of ABC Size
2 class AbcSize
3 def demonstrate
4 a = 'foo'
5 b = 'bar'
6 c = rand(2).even? ? 'baz' : 'quux'
7 a + b + c # a.+ b.+ c
8 end
9 end
Assignments: 3
Branches: 4
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Example
Let’s count!
1 # Demonstration of ABC Size
2 class AbcSize
3 def demonstrate
4 a = 'foo'
5 b = 'bar'
6 c = rand(2).even? ? 'baz' : 'quux'
7 a + b + c # a.+ b.+ c
8 end
9 end
Assignments: 3
Branches: 4
Conditionals:
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Example
Let’s count!
1 # Demonstration of ABC Size
2 class AbcSize
3 def demonstrate
4 a = 'foo'
5 b = 'bar'
6 c = rand(2).even? ? 'baz' : 'quux'
7 a + b + c # a.+ b.+ c
8 end
9 end
Assignments: 3
Branches: 4
Conditionals: 1
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Example
Let’s count!
1 # Demonstration of ABC Size
2 class AbcSize
3 def demonstrate
4 a = 'foo'
5 b = 'bar'
6 c = rand(2).even? ? 'baz' : 'quux'
7 a + b + c # a.+ b.+ c
8 end
9 end
Assignments: 3
Branches: 4
Conditionals: 1
AbcSize:
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Example
Let’s count!
1 # Demonstration of ABC Size
2 class AbcSize
3 def demonstrate
4 a = 'foo'
5 b = 'bar'
6 c = rand(2).even? ? 'baz' : 'quux'
7 a + b + c # a.+ b.+ c
8 end
9 end
Assignments: 3
Branches: 4
Conditionals: 1
AbcSize:
√
26 ≈ 5.1
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What does Rubocop say?
code/abc_size.rb
: 6 : 3 : C: Metrics/AbcSize :
Assignment Branch Condition s i z e f o r demonstrate
i s too high . [<3, 4 , 1> 5.1/0]
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Reducing ABC Size
For Ruby, use Rubocop
The main way to reduce ABC size is refactoring. It’s that simple.
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Reducing ABC Size
For Ruby, use Rubocop
The main way to reduce ABC size is refactoring. It’s that simple.
Well-factored programs tend to have lower ABC Size.
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Reducing ABC Size
For Ruby, use Rubocop
The main way to reduce ABC size is refactoring. It’s that simple.
Well-factored programs tend to have lower ABC Size.
It’s really that simple.
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
One major caveat...
...you have to do the work
THE MOST IMPORTANT PART IS TO ENABLE THE METRIC!
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
One major caveat...
...you have to do the work
THE MOST IMPORTANT PART IS TO ENABLE THE METRIC!
1 Metrics/AbcSize:
2 Enabled: true
3 Max: 15 # Rubocop default
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Other complexity measures
Same code, different information
Others for later:
• Cyclomatic (McCabe) Complexity
• Perceived Complexity
• LCOM (Lack of Cohesion of Methods)
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Have fun!
and remember
ABC is a simple metric, it’s not a silver bullet. Not every method is
amenable to low ABC size. It’s a tool, and very good tool at that.
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
References
• ABC Software Metric
• Rubocop default.yml
• C2 Wiki: AbcMetric
ABC Sise
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Questions?
ABC Sise

Weitere ähnliche Inhalte

Ähnlich wie ABC Size - An Easy Code Complexity Metric

Scilabisnotnaive
ScilabisnotnaiveScilabisnotnaive
Scilabisnotnaive
zan
 
Teoria y problemas de numeros racionales qa412 ccesa007
Teoria y problemas de numeros racionales qa412 ccesa007Teoria y problemas de numeros racionales qa412 ccesa007
Teoria y problemas de numeros racionales qa412 ccesa007
Demetrio Ccesa Rayme
 
igcse_edexcel_math-_gold_qp1_-igcse_9-1_.pdf
igcse_edexcel_math-_gold_qp1_-igcse_9-1_.pdfigcse_edexcel_math-_gold_qp1_-igcse_9-1_.pdf
igcse_edexcel_math-_gold_qp1_-igcse_9-1_.pdf
TeenaSheikh
 
0580 s17 qp_42 exam - copy
0580 s17 qp_42 exam - copy0580 s17 qp_42 exam - copy
0580 s17 qp_42 exam - copy
mend Oyunchimeg
 
Tdd for BT E2E test community
Tdd for BT E2E test communityTdd for BT E2E test community
Tdd for BT E2E test community
Kerry Buckley
 
Teoria y problemas de numeros racionales qa312 ccesa007
Teoria y problemas de numeros racionales qa312 ccesa007Teoria y problemas de numeros racionales qa312 ccesa007
Teoria y problemas de numeros racionales qa312 ccesa007
Demetrio Ccesa Rayme
 
Monte Carlo Simulation for project estimates v1.0
Monte Carlo Simulation for project estimates v1.0Monte Carlo Simulation for project estimates v1.0
Monte Carlo Simulation for project estimates v1.0
PMILebanonChapter
 
Microsoft interview walkthrough
Microsoft interview walkthroughMicrosoft interview walkthrough
Microsoft interview walkthrough
Aayush Bahuguna
 
PA 1c. Decision VariablesabcdCalculated values0.21110.531110.09760.docx
PA 1c. Decision VariablesabcdCalculated values0.21110.531110.09760.docxPA 1c. Decision VariablesabcdCalculated values0.21110.531110.09760.docx
PA 1c. Decision VariablesabcdCalculated values0.21110.531110.09760.docx
gerardkortney
 

Ähnlich wie ABC Size - An Easy Code Complexity Metric (20)

Introduction to MATLAB Programming and Numerical Methods for Engineers 1st Ed...
Introduction to MATLAB Programming and Numerical Methods for Engineers 1st Ed...Introduction to MATLAB Programming and Numerical Methods for Engineers 1st Ed...
Introduction to MATLAB Programming and Numerical Methods for Engineers 1st Ed...
 
Testes automatizados o time e o cliente saem ganhando! @ Agile Vale 2014
Testes automatizados o time e o cliente saem ganhando! @ Agile Vale 2014Testes automatizados o time e o cliente saem ganhando! @ Agile Vale 2014
Testes automatizados o time e o cliente saem ganhando! @ Agile Vale 2014
 
Run Your Business 6X Faster at Lower Costs!
Run Your Business 6X Faster at Lower Costs!Run Your Business 6X Faster at Lower Costs!
Run Your Business 6X Faster at Lower Costs!
 
Data Mining: Concepts and Techniques (3rd ed.) — Chapter 5
Data Mining:  Concepts and Techniques (3rd ed.)— Chapter 5 Data Mining:  Concepts and Techniques (3rd ed.)— Chapter 5
Data Mining: Concepts and Techniques (3rd ed.) — Chapter 5
 
05 practice paper_3_h_set_a
05 practice paper_3_h_set_a05 practice paper_3_h_set_a
05 practice paper_3_h_set_a
 
Scilabisnotnaive
ScilabisnotnaiveScilabisnotnaive
Scilabisnotnaive
 
Scilab is not naive
Scilab is not naiveScilab is not naive
Scilab is not naive
 
Teoria y problemas de numeros racionales qa412 ccesa007
Teoria y problemas de numeros racionales qa412 ccesa007Teoria y problemas de numeros racionales qa412 ccesa007
Teoria y problemas de numeros racionales qa412 ccesa007
 
0580_w14_qp_22
0580_w14_qp_220580_w14_qp_22
0580_w14_qp_22
 
igcse_edexcel_math-_gold_qp1_-igcse_9-1_.pdf
igcse_edexcel_math-_gold_qp1_-igcse_9-1_.pdfigcse_edexcel_math-_gold_qp1_-igcse_9-1_.pdf
igcse_edexcel_math-_gold_qp1_-igcse_9-1_.pdf
 
0580 s17 qp_42 exam - copy
0580 s17 qp_42 exam - copy0580 s17 qp_42 exam - copy
0580 s17 qp_42 exam - copy
 
Assembly Codes in C Programmes - A Short Notes by Arun Umrao
Assembly Codes in C Programmes - A Short Notes by Arun UmraoAssembly Codes in C Programmes - A Short Notes by Arun Umrao
Assembly Codes in C Programmes - A Short Notes by Arun Umrao
 
Tdd for BT E2E test community
Tdd for BT E2E test communityTdd for BT E2E test community
Tdd for BT E2E test community
 
CYB 130 Education Specialist |tutorialrank.com
CYB 130 Education Specialist |tutorialrank.comCYB 130 Education Specialist |tutorialrank.com
CYB 130 Education Specialist |tutorialrank.com
 
Teoria y problemas de numeros racionales qa312 ccesa007
Teoria y problemas de numeros racionales qa312 ccesa007Teoria y problemas de numeros racionales qa312 ccesa007
Teoria y problemas de numeros racionales qa312 ccesa007
 
0580 s15 qp_11 (1)
0580 s15 qp_11 (1)0580 s15 qp_11 (1)
0580 s15 qp_11 (1)
 
Monte Carlo Simulation for project estimates v1.0
Monte Carlo Simulation for project estimates v1.0Monte Carlo Simulation for project estimates v1.0
Monte Carlo Simulation for project estimates v1.0
 
Microsoft interview walkthrough
Microsoft interview walkthroughMicrosoft interview walkthrough
Microsoft interview walkthrough
 
PA 1c. Decision VariablesabcdCalculated values0.21110.531110.09760.docx
PA 1c. Decision VariablesabcdCalculated values0.21110.531110.09760.docxPA 1c. Decision VariablesabcdCalculated values0.21110.531110.09760.docx
PA 1c. Decision VariablesabcdCalculated values0.21110.531110.09760.docx
 
Unsupervised learning
Unsupervised learning Unsupervised learning
Unsupervised learning
 

Kürzlich hochgeladen

ALCOHOL PRODUCTION- Beer Brewing Process.pdf
ALCOHOL PRODUCTION- Beer Brewing Process.pdfALCOHOL PRODUCTION- Beer Brewing Process.pdf
ALCOHOL PRODUCTION- Beer Brewing Process.pdf
Madan Karki
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manual
BalamuruganV28
 
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
drjose256
 

Kürzlich hochgeladen (20)

Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptx
 
ALCOHOL PRODUCTION- Beer Brewing Process.pdf
ALCOHOL PRODUCTION- Beer Brewing Process.pdfALCOHOL PRODUCTION- Beer Brewing Process.pdf
ALCOHOL PRODUCTION- Beer Brewing Process.pdf
 
Geometric constructions Engineering Drawing.pdf
Geometric constructions Engineering Drawing.pdfGeometric constructions Engineering Drawing.pdf
Geometric constructions Engineering Drawing.pdf
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
 
Piping and instrumentation diagram p.pdf
Piping and instrumentation diagram p.pdfPiping and instrumentation diagram p.pdf
Piping and instrumentation diagram p.pdf
 
Filters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility ApplicationsFilters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility Applications
 
Multivibrator and its types defination and usges.pptx
Multivibrator and its types defination and usges.pptxMultivibrator and its types defination and usges.pptx
Multivibrator and its types defination and usges.pptx
 
Raashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashid final report on Embedded Systems
Raashid final report on Embedded Systems
 
Research Methodolgy & Intellectual Property Rights Series 2
Research Methodolgy & Intellectual Property Rights Series 2Research Methodolgy & Intellectual Property Rights Series 2
Research Methodolgy & Intellectual Property Rights Series 2
 
Insurance management system project report.pdf
Insurance management system project report.pdfInsurance management system project report.pdf
Insurance management system project report.pdf
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...
 
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
 
Electrical shop management system project report.pdf
Electrical shop management system project report.pdfElectrical shop management system project report.pdf
Electrical shop management system project report.pdf
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manual
 
Developing a smart system for infant incubators using the internet of things ...
Developing a smart system for infant incubators using the internet of things ...Developing a smart system for infant incubators using the internet of things ...
Developing a smart system for infant incubators using the internet of things ...
 
Introduction to Artificial Intelligence and History of AI
Introduction to Artificial Intelligence and History of AIIntroduction to Artificial Intelligence and History of AI
Introduction to Artificial Intelligence and History of AI
 
Dynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptxDynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptx
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptx
 
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTUUNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
 
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
 

ABC Size - An Easy Code Complexity Metric