SlideShare a Scribd company logo
1 of 22
Download to read offline
Cyclomatic
Complexity
Cyclomatic
Complexity
Presented By:
Nikita Kesharwani
Overview..
 What is Software Design?
 Software Metrics.
 Complexity.
 Cyclomatic Complexity.
 Example.
 Determine Cyclometic Complexity.
 How this metrics is useful for software Testing?
 Uses of Cyclometic Complexity.
 Conclusion.
What is a Software Design?
 Software Design is a process to
transform user requirements into
some suitable form which helps the
programmer in software coding and
implementation.
 To improve quality of a software, we need
to measure various aspects:-
 Size,
 Complexity,
 Maintainability of software etc..
Is Software Metrics Required...
 Choosing the right metrics can make the
difference between success and failure of a
project.
 The Term Complexity Stands for state of
events or things, which have multiple
interconnected links and highly complicated
structures.
Complexity...
Cont...
 Complexity can be interpreted in different ways:-
Problem complexity (also called computational complexity)
measures the complexity of the underlying problem.
Algorithmic complexity reflects the complexity of the
algorithm implemented to solve the problem.
Structural complexity measures the structure of the software
used to implement the algorithm.
Cognitive complexity measures the effort required to
understand the software.
Cyclometic Complexity..
 A program consists of statements.
 Some of them are decision making which change
the flow of program.
 Developed by McCabe, in 1976.
 Measures the number of linearly independent
paths through a program.
 Lower the Program's cyclomatic complexity,
lower the risk to modify and easier to understand.
Cont..
 The complexity would be 1, since
there would be only a single path
through the code.
 If the code had one single-condition IF
statement, there would be two paths
through the code, so the complexity
would be 2.
Determine Cyclometic Complexity..
There are several methods:
1. Cyclomatic complexity = edges - nodes + 2p
2. Cyclomatic complexity = Number of Predicate
Nodes + 1
3. Cyclomatic complexity = Number of regions in
the control flow graph
Example..
Cyclometic Complexity = Edges –Nodes + 2P
P = Number of unconnected parts of the graph.
Another Example..
 [1—2—6]
 [1—2—3—5—2—6]
 [1—2—3—4—5—2—6]
Cyclomatic Complexity
= 7 - 6 + 2*1 = 3
In this Example:-
Cont..
Cyclomatic Complexity
= 7 - 8 + 2*2 = 3
In this Example:-
Cont..
Cyclomatic Complexity
= 2 + 1 = 3
In this Example:-
Cyclomatic complexity= Number of Predicate
Nodes + 1
Cont..
Cyclomatic Complexity
= 3
In this Example:-
Cyclomatic complexity = number of regions in
the control flow graph.
How this metric is useful
for software testing..
 Basis Path testing is one of White box technique
and it guarantees to execute at least one statement
during testing.
 It checks each linearly independent path through
the program.
Cont..
 Which means number of test cases, will be
equivalent to the cyclomatic complexity of the
program.
Cont..
 As you can deduce from the above table, even the
smallest application written taken as a whole will
be have very high Cyclomatic complexity, so it's
measured at function level.
 Industry standard is not to have any function in
your application having Cyclomatic complexity
greater than 10.
Cont..
 The advantage of this is a function can have
maximum test case of 10.
 And research has proven that most computer
programmers can easily read and modify functions
that are having Cyclomatic complexity less than or
equal to 10.
 As cognitive load on human mind is less.
Uses of Cyclomatic Complexity..
Cyclomatic Complexity can prove to be very helpful in :-
 Helps developers and testers to determine
independent path executions.
 Developers can assure that all the paths have
been tested at least once.
 Helps us to focus more on the uncovered paths.
 Evaluate the risk associated with the application
or program.
Conclusion..
 It is mainly used to evaluate complexity of a
program.
 If the decision points are more, then complexity
of the program is more.
 If program has high complexity number, then
probability of error is high with increased time for
maintenance and trouble shoot.
Cyclomatic complexity
Cyclomatic complexity

More Related Content

What's hot

Basis path testing
Basis path testingBasis path testing
Basis path testingHoa Le
 
Design Concept software engineering
Design Concept software engineeringDesign Concept software engineering
Design Concept software engineeringDarshit Metaliya
 
Software engineering a practitioners approach 8th edition pressman solutions ...
Software engineering a practitioners approach 8th edition pressman solutions ...Software engineering a practitioners approach 8th edition pressman solutions ...
Software engineering a practitioners approach 8th edition pressman solutions ...Drusilla918
 
A generic view of software engineering
A generic view of software engineeringA generic view of software engineering
A generic view of software engineeringInocentshuja Ahmad
 
formal verification
formal verificationformal verification
formal verificationToseef Aslam
 
Programming team structure
Programming team structureProgramming team structure
Programming team structureNancyBeaulah_R
 
Chapter 1 2 - some size factors
Chapter 1   2 - some size factorsChapter 1   2 - some size factors
Chapter 1 2 - some size factorsNancyBeaulah_R
 
Estimating Software Maintenance Costs
Estimating Software Maintenance CostsEstimating Software Maintenance Costs
Estimating Software Maintenance Costslalithambiga kamaraj
 
Software Engineering : Requirement Analysis & Specification
Software Engineering : Requirement Analysis & SpecificationSoftware Engineering : Requirement Analysis & Specification
Software Engineering : Requirement Analysis & SpecificationAjit Nayak
 
Evolutionary process models se.ppt
Evolutionary process models se.pptEvolutionary process models se.ppt
Evolutionary process models se.pptbhadjaashvini1
 
Formal Specification in Software Engineering SE9
Formal Specification in Software Engineering SE9Formal Specification in Software Engineering SE9
Formal Specification in Software Engineering SE9koolkampus
 
Software Design and Modularity
Software Design and ModularitySoftware Design and Modularity
Software Design and ModularityDanyal Ahmad
 
Software Engineering (Short & Long Questions)
Software Engineering (Short & Long Questions)Software Engineering (Short & Long Questions)
Software Engineering (Short & Long Questions)MuhammadTalha436
 
Software engineering note
Software engineering noteSoftware engineering note
Software engineering noteNeelamani Samal
 

What's hot (20)

Basis path testing
Basis path testingBasis path testing
Basis path testing
 
Design Concept software engineering
Design Concept software engineeringDesign Concept software engineering
Design Concept software engineering
 
Software engineering a practitioners approach 8th edition pressman solutions ...
Software engineering a practitioners approach 8th edition pressman solutions ...Software engineering a practitioners approach 8th edition pressman solutions ...
Software engineering a practitioners approach 8th edition pressman solutions ...
 
White box ppt
White box pptWhite box ppt
White box ppt
 
A generic view of software engineering
A generic view of software engineeringA generic view of software engineering
A generic view of software engineering
 
formal verification
formal verificationformal verification
formal verification
 
Programming team structure
Programming team structureProgramming team structure
Programming team structure
 
Chapter 1 2 - some size factors
Chapter 1   2 - some size factorsChapter 1   2 - some size factors
Chapter 1 2 - some size factors
 
Estimating Software Maintenance Costs
Estimating Software Maintenance CostsEstimating Software Maintenance Costs
Estimating Software Maintenance Costs
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Software Engineering : Requirement Analysis & Specification
Software Engineering : Requirement Analysis & SpecificationSoftware Engineering : Requirement Analysis & Specification
Software Engineering : Requirement Analysis & Specification
 
Staffing level estimation
Staffing level estimation Staffing level estimation
Staffing level estimation
 
Evolutionary process models se.ppt
Evolutionary process models se.pptEvolutionary process models se.ppt
Evolutionary process models se.ppt
 
Formal Specification in Software Engineering SE9
Formal Specification in Software Engineering SE9Formal Specification in Software Engineering SE9
Formal Specification in Software Engineering SE9
 
Software Design and Modularity
Software Design and ModularitySoftware Design and Modularity
Software Design and Modularity
 
Incremental process model
Incremental  process  modelIncremental  process  model
Incremental process model
 
Cocomo model
Cocomo modelCocomo model
Cocomo model
 
Software Engineering (Short & Long Questions)
Software Engineering (Short & Long Questions)Software Engineering (Short & Long Questions)
Software Engineering (Short & Long Questions)
 
Software engineering note
Software engineering noteSoftware engineering note
Software engineering note
 
Daa notes 1
Daa notes 1Daa notes 1
Daa notes 1
 

Similar to Cyclomatic complexity

How to calculte Cyclomatic Complexity through various methods
How to calculte Cyclomatic Complexity through various methodsHow to calculte Cyclomatic Complexity through various methods
How to calculte Cyclomatic Complexity through various methodsharsimratDeo
 
cyclomatic complecity.pptx
cyclomatic complecity.pptxcyclomatic complecity.pptx
cyclomatic complecity.pptxujjwalmatoliya
 
Qat09 presentations dxw07u
Qat09 presentations dxw07uQat09 presentations dxw07u
Qat09 presentations dxw07uShubham Sharma
 
Program concep sequential statements
Program concep sequential statementsProgram concep sequential statements
Program concep sequential statementsankurkhanna
 
A WHITE BOX TESTING TECHNIQUE IN SOFTWARE TESTING : BASIS PATH TESTING
A WHITE BOX TESTING TECHNIQUE IN SOFTWARE TESTING : BASIS PATH TESTINGA WHITE BOX TESTING TECHNIQUE IN SOFTWARE TESTING : BASIS PATH TESTING
A WHITE BOX TESTING TECHNIQUE IN SOFTWARE TESTING : BASIS PATH TESTINGJournal For Research
 
Software Engineering Fundamentals in Computer Science
Software Engineering Fundamentals in Computer ScienceSoftware Engineering Fundamentals in Computer Science
Software Engineering Fundamentals in Computer ScienceArti Parab Academics
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)praveena p
 
Chapter 09 design and analysis of algorithms
Chapter 09  design and analysis of algorithmsChapter 09  design and analysis of algorithms
Chapter 09 design and analysis of algorithmsPraveen M Jigajinni
 
GE3151 PSPP _Unit 1 notes and Question bank.pdf
GE3151 PSPP _Unit 1 notes and Question bank.pdfGE3151 PSPP _Unit 1 notes and Question bank.pdf
GE3151 PSPP _Unit 1 notes and Question bank.pdfAsst.prof M.Gokilavani
 
Managing Develop of Large Systems
Managing Develop of Large SystemsManaging Develop of Large Systems
Managing Develop of Large SystemsDaniloPereira341965
 
02 intel v_tune_session_02
02 intel v_tune_session_0202 intel v_tune_session_02
02 intel v_tune_session_02Vivek chan
 
Se 381 - lec 25 - 32 - 12 may29 - program size and cost estimation models
Se 381 - lec 25 - 32 - 12 may29 - program size and cost estimation modelsSe 381 - lec 25 - 32 - 12 may29 - program size and cost estimation models
Se 381 - lec 25 - 32 - 12 may29 - program size and cost estimation modelsbabak danyal
 
Naging The Development Of Large Software Systems
Naging The Development Of Large Software Systems Naging The Development Of Large Software Systems
Naging The Development Of Large Software Systems Software Guru
 
Software Testing and Quality Assurance Assignment 2
Software Testing and Quality Assurance Assignment 2Software Testing and Quality Assurance Assignment 2
Software Testing and Quality Assurance Assignment 2Gurpreet singh
 

Similar to Cyclomatic complexity (20)

How to calculte Cyclomatic Complexity through various methods
How to calculte Cyclomatic Complexity through various methodsHow to calculte Cyclomatic Complexity through various methods
How to calculte Cyclomatic Complexity through various methods
 
cyclomatic complecity.pptx
cyclomatic complecity.pptxcyclomatic complecity.pptx
cyclomatic complecity.pptx
 
Qat09 presentations dxw07u
Qat09 presentations dxw07uQat09 presentations dxw07u
Qat09 presentations dxw07u
 
Program concep sequential statements
Program concep sequential statementsProgram concep sequential statements
Program concep sequential statements
 
A WHITE BOX TESTING TECHNIQUE IN SOFTWARE TESTING : BASIS PATH TESTING
A WHITE BOX TESTING TECHNIQUE IN SOFTWARE TESTING : BASIS PATH TESTINGA WHITE BOX TESTING TECHNIQUE IN SOFTWARE TESTING : BASIS PATH TESTING
A WHITE BOX TESTING TECHNIQUE IN SOFTWARE TESTING : BASIS PATH TESTING
 
Intro-Soft-Engg-2.pptx
Intro-Soft-Engg-2.pptxIntro-Soft-Engg-2.pptx
Intro-Soft-Engg-2.pptx
 
Software Engineering Fundamentals in Computer Science
Software Engineering Fundamentals in Computer ScienceSoftware Engineering Fundamentals in Computer Science
Software Engineering Fundamentals in Computer Science
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)
 
Software design
Software designSoftware design
Software design
 
Software metrics
Software metricsSoftware metrics
Software metrics
 
Introduction to problem solving in C
Introduction to problem solving in CIntroduction to problem solving in C
Introduction to problem solving in C
 
Chapter 09 design and analysis of algorithms
Chapter 09  design and analysis of algorithmsChapter 09  design and analysis of algorithms
Chapter 09 design and analysis of algorithms
 
UDP Report
UDP ReportUDP Report
UDP Report
 
GE3151 PSPP _Unit 1 notes and Question bank.pdf
GE3151 PSPP _Unit 1 notes and Question bank.pdfGE3151 PSPP _Unit 1 notes and Question bank.pdf
GE3151 PSPP _Unit 1 notes and Question bank.pdf
 
Managing Develop of Large Systems
Managing Develop of Large SystemsManaging Develop of Large Systems
Managing Develop of Large Systems
 
02 intel v_tune_session_02
02 intel v_tune_session_0202 intel v_tune_session_02
02 intel v_tune_session_02
 
Se 381 - lec 25 - 32 - 12 may29 - program size and cost estimation models
Se 381 - lec 25 - 32 - 12 may29 - program size and cost estimation modelsSe 381 - lec 25 - 32 - 12 may29 - program size and cost estimation models
Se 381 - lec 25 - 32 - 12 may29 - program size and cost estimation models
 
Naging The Development Of Large Software Systems
Naging The Development Of Large Software Systems Naging The Development Of Large Software Systems
Naging The Development Of Large Software Systems
 
Software Testing and Quality Assurance Assignment 2
Software Testing and Quality Assurance Assignment 2Software Testing and Quality Assurance Assignment 2
Software Testing and Quality Assurance Assignment 2
 
Chapter 8 Testing Tactics.ppt
Chapter 8 Testing Tactics.pptChapter 8 Testing Tactics.ppt
Chapter 8 Testing Tactics.ppt
 

Recently uploaded

Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 

Recently uploaded (20)

Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 

Cyclomatic complexity

  • 2. Overview..  What is Software Design?  Software Metrics.  Complexity.  Cyclomatic Complexity.  Example.  Determine Cyclometic Complexity.  How this metrics is useful for software Testing?  Uses of Cyclometic Complexity.  Conclusion.
  • 3. What is a Software Design?  Software Design is a process to transform user requirements into some suitable form which helps the programmer in software coding and implementation.
  • 4.  To improve quality of a software, we need to measure various aspects:-  Size,  Complexity,  Maintainability of software etc.. Is Software Metrics Required...  Choosing the right metrics can make the difference between success and failure of a project.
  • 5.  The Term Complexity Stands for state of events or things, which have multiple interconnected links and highly complicated structures. Complexity...
  • 6. Cont...  Complexity can be interpreted in different ways:- Problem complexity (also called computational complexity) measures the complexity of the underlying problem. Algorithmic complexity reflects the complexity of the algorithm implemented to solve the problem. Structural complexity measures the structure of the software used to implement the algorithm. Cognitive complexity measures the effort required to understand the software.
  • 7. Cyclometic Complexity..  A program consists of statements.  Some of them are decision making which change the flow of program.  Developed by McCabe, in 1976.  Measures the number of linearly independent paths through a program.  Lower the Program's cyclomatic complexity, lower the risk to modify and easier to understand.
  • 8. Cont..  The complexity would be 1, since there would be only a single path through the code.  If the code had one single-condition IF statement, there would be two paths through the code, so the complexity would be 2.
  • 9. Determine Cyclometic Complexity.. There are several methods: 1. Cyclomatic complexity = edges - nodes + 2p 2. Cyclomatic complexity = Number of Predicate Nodes + 1 3. Cyclomatic complexity = Number of regions in the control flow graph
  • 10. Example.. Cyclometic Complexity = Edges –Nodes + 2P P = Number of unconnected parts of the graph.
  • 11. Another Example..  [1—2—6]  [1—2—3—5—2—6]  [1—2—3—4—5—2—6] Cyclomatic Complexity = 7 - 6 + 2*1 = 3 In this Example:-
  • 12. Cont.. Cyclomatic Complexity = 7 - 8 + 2*2 = 3 In this Example:-
  • 13. Cont.. Cyclomatic Complexity = 2 + 1 = 3 In this Example:- Cyclomatic complexity= Number of Predicate Nodes + 1
  • 14. Cont.. Cyclomatic Complexity = 3 In this Example:- Cyclomatic complexity = number of regions in the control flow graph.
  • 15. How this metric is useful for software testing..  Basis Path testing is one of White box technique and it guarantees to execute at least one statement during testing.  It checks each linearly independent path through the program.
  • 16. Cont..  Which means number of test cases, will be equivalent to the cyclomatic complexity of the program.
  • 17. Cont..  As you can deduce from the above table, even the smallest application written taken as a whole will be have very high Cyclomatic complexity, so it's measured at function level.  Industry standard is not to have any function in your application having Cyclomatic complexity greater than 10.
  • 18. Cont..  The advantage of this is a function can have maximum test case of 10.  And research has proven that most computer programmers can easily read and modify functions that are having Cyclomatic complexity less than or equal to 10.  As cognitive load on human mind is less.
  • 19. Uses of Cyclomatic Complexity.. Cyclomatic Complexity can prove to be very helpful in :-  Helps developers and testers to determine independent path executions.  Developers can assure that all the paths have been tested at least once.  Helps us to focus more on the uncovered paths.  Evaluate the risk associated with the application or program.
  • 20. Conclusion..  It is mainly used to evaluate complexity of a program.  If the decision points are more, then complexity of the program is more.  If program has high complexity number, then probability of error is high with increased time for maintenance and trouble shoot.