Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSE460 Lecture 33

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

CSE460 Lecture 33

Software Analysis and Design
Software Quality Metrics II
(202011)

Avatar for Javier Gonzalez-Sanchez

Javier Gonzalez-Sanchez PRO

August 02, 2020
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. jgs CSE 460 Software Analysis and Design Lecture 33: Software

    Quality Metrics II Dr. Javier Gonzalez-Sanchez [email protected] javiergs.engineering.asu.edu | javiergs.com PERALTA 230U Office Hours: By appointment
  2. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 3 jgs

    Size Metrics § LOC – Lines of Code Metric. All lines that are not comments. Including lines of a single brace or parenthesis. § eLOC (effective Lines of Code) Metric. All lines that are not comments, blanks or standalone braces or parenthesis. § lLOC (logical Lines of Code) Metric. These statements are terminated with a semi- colon. The control line for the "for" loop contain two semi-colons but accounts for only one semi colon.
  3. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 4 jgs

    Understandability Metrics § Comment Percent = Comment Line Count / (LOC) x 100 § White Space Percentage = #spaces / (#spaces + #characters) * 100
  4. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 5 jgs

    Function Metrics Cyclomatic Complexity = Conditional_Nodes + 1 // CC = 3 + 1 = 4 (Condition nodes are 1,2 and 3 nodes) i = 0; n=4; while (i<n-1) { j = i + 1; while (j<n) { if (A[i]<A[j]) swap(A[i], A[j]); } i=i+1; }
  5. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 10 jgs

    Numbers LOC eLOC lLOC Cyclomatic Complexity m1 m2 m3 m4 m5 main Total
  6. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 13 jgs

    Example A § 3 files § 24 methods § 394 lines § 326 LOC § 285 eLOC § 182 lLOC § 20 Lcomments § Comments 5.1% § Blank lines 12.2% § Spaces: 21.0% (79% code) § Max CC: 6 § Average CC: 1.46 § 5 files § 21 methods § 522 lines § 412 LOC § 356 eLOC § 276 lLOC § 72 Lcomments § Comments 13.8% § Blank lines 7.3% § Spaces: 26.7% (73.3% code) § Max CC: 7 § Average CC: 2.24
  7. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 16 jgs

    • Instability = Cout (Cin + Cout) Stable Abstraction Principle (SAP)
  8. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 17 jgs

    Distance § Distance: how far a package is away from the Main Sequence § D = A + I – 1 § Values -1 to 1 § Absolute Distance |D|
  9. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 18 jgs

    Example ITeamA = 6 / 0 + 6 = 1 ATeamA = 0 DTeamA = 0 + 1 – 1 = 0 IJlabel = 0 / 4 + 0 = 0 AJlabel = 0 DJlabel = 0 + 0 – 1 = -1 |Djlabel | = 1 Pain Zone (just an example!)
  10. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 19 jgs

    Stable Dependency Principle (SDP) § Every dependency between modules should terminate on a module whose Instability is less than or equal to the depending module's Instability. § Every dependency between modules should terminate on a module whose Abstractness is greater than or equal to the depending module's Abstractness.
  11. jgs CSE 460 Software Analysis and Design Javier Gonzalez-Sanchez [email protected]

    Fall 2020 Disclaimer. These slides can only be used as study material for the class CSE460 at ASU. They cannot be distributed or used for another purpose.