Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Successfully reported this slideshow.

Like this presentation? Why not share!

- What to Upload to SlideShare by SlideShare 5906518 views
- Customer Code: Creating a Company C... by HubSpot 4385266 views
- Be A Great Product Leader (Amplify,... by Adam Nash 983681 views
- Trillion Dollar Coach Book (Bill Ca... by Eric Schmidt 1158637 views
- APIdays Paris 2019 - Innovation @ s... by apidays 1341967 views
- A few thoughts on work life-balance by Wim Vanderbauwhede 1010918 views

974 views

Published on

Cyclomatic complexity - The complexity of algorithms

Published in:
Software

No Downloads

Total views

974

On SlideShare

0

From Embeds

0

Number of Embeds

0

Shares

0

Downloads

31

Comments

1

Likes

1

No notes for slide

- 1. Cyclomatic complexity The complexity of algorithms
- 2. Code Coverage Where Does It Fit? - Tom McCabe (tmccabe@mccabe.com) 2 Test Focus: Requirements Validation Audience: User Code Coverage: Supplemental Positive Test: Testing things in your specs that you already know about Test Focus: Implementation Validation Audience: Code Code Coverage: Primary Negative Test: Testing things that may not be in your specs but in the implementation White Box vs. Black Box Testing Black Box Testing White Box Testing • *or Breadth of Testing vs. Depth of Testing as detailed in Department of Army Pamphlet 73-1
- 3. 18 times n It is IMPOSSIBLE to test All Statistical Paths n So, from structural coverage view, When Should We Stop Testing? n Not care? (planes do, missiles do) n All lines? n All branches? n All cyclomatic paths? 18 0 10Optimum Number of Tests? All Statistical Paths = 10 18 If allow 1 Nanosecond per test, time is : T = 10 x 3600 x 24 x 365 9 10 18 = 31.7 Years IV. Testing Software for Reliability - Structured Testing Impossibility of Testing Everything
- 4. A complexity measure •Definition: The cyclomatic number v(G) of a graph G with e edges, n nodes, and p connected components is e-n+p. •Theorem: In a strongly connected graph the cyclomatic number is equal to the maximal number of linearly independent circuits.
- 5. With this example • V(G) = 10 – 6 + 1 = 5 • # of regions = 5
- 6. Pick paths for the 5 circuits • Using theorem 1 we choose a set of circuits that are paths. The following set B is a basis set of paths. • B: (abef) , (a(be)2f) , ((abe)2f) , (acf) , (adcf) • Linear combinations of paths in B will generate any path. For example, • (abea(be)3f) = 2(a(be)2f) – (abef) • (a(be)2abef) = (a(be)2f)+((abe)2f)-(abef)
- 7. Methods of computing v(G) • E-n+2 • # decisions + 1 • # of regions in a planar flow graph
- 8. 8 Function A Complexity = 20 5.17s Unstructuredness (evg) = 1 Function B Complexity = 18 Unstructuredness (evg) = 17 So B is MUCH harder to maintain! Complexity (decisions) & # lines here are similar, but ...
- 9. Applications Testing Essential complexity --- reverse engineering Design Complexity ---- system integration Data complexity --- Y2K testing Pareto Distribution of errors --- reverse engineering Code Breaker ---- Reuse Security threats Data Slicing ----- Reuse Code walkthroughs ---- validation Design validation Requirements Validation
- 10. Google book search – McCabe Complexity – 22,000 books
- 11. Google web search (McCabe complexity): 456,000 references In 2009 Tom McCabe’s publication on Software Complexity was chosen as one of the retrospective 23 highest impact papers in computer science by the ACM-SIGSOFT

No public clipboards found for this slide

Login to see the comments