Share
Embed
Transcript
34 slides
-
CSC 3100 Fundamentals of Software Engineering Lecture 12. Software Metrics
Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.phd ffi o ce: 14 -227 -
Abstractness • It is the degree to which implement tion
• It is cl ss or p ck ge emph sizes bstr ction over concrete v lue 0 to 1: • For p ck ges, It is the r tio of bstr ct cl sses or interf ces to the tot l number of cl sses within p ck ge. a a a a a a a a a a a a a a a a a a concrete cl ss nd 1 for n interf ce or bstr ct cl sses a a a a a a a a a a a a a • For cl sses, It is 0 for -
Instability • Indic tes whether: ( ) the item is
m inly used by others (st ble – h rd to ch nge); or (b) it m inly depends on other items (in-st ble – ch nge ble). • It is v lue between 0 nd 1: • 0 only incoming dependencies to a a a a a a a a a a a a a • 1 (only outgoing dependencies). -
Distance • Dist nce: how f r p ck ge
is w y from the M in Sequence • D=A+I–1 • V lues -1 to 1 a a a a a a a a a a • Absolute Dist nce |D| -
Distance 1 Abstract e th Abstractness Useless i ma n
c en qu se e Painful Concrete 0 0 Stable Hard to Change Only incoming dependencies Instability 1 Unstable Changeable Only outgoing dependencies -
Function Metrics • Cyclomatic Complexity. It is a quantitative measure
of the number of linearly independent paths. • P ths occur when "while,” "for,” "if,” "c se," nd "goto" keywords ppe r within the function. • If the source code cont ined no control low st tements (condition ls or decision points), the complexity would be 1 • If the code h d one single-condition IF st tement, there would be two p ths through the code: one where the IF st tement ev lu tes to TRUE nd nother one where it considers to be FALSE. a a a a a a a a a a f a a a a a a a • Two nested single-condition IFs, or one block with two conditions, would produce of 3. complexity -
Cyclomatic Complexity CC = Edge - Node + 2 Or
CC = ConditionalNodes + 1 -
Cyclomatic Complexity 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; } // CC = 9 - 7 + 2 = 4 // CC = 3 + 1 = 4 (Condition nodes are 1,2 and 3 nodes) // A set of possible execution path of a program // 1, 7 // 1, 2, 6, 1, 7 // 1, 2, 3, 4, 5, 2, 6, 1, 7 // 1, 2, 3, 5, 2, 6, 1, 7 -
Cyclomatic Complexity Complexity Number Meaning 1-10 Structured and well written
code High Testability Cost and Effort is less 10-20 Complex Code Medium Testability Cost and effort is Medium 20-40 Very complex Code Low Testability Cost and Effort are high >40 Not at all testable Very high Cost and Effort -
Assignment 03 START WITH EXISTING CODE DELIVER A BETTER DESIGN
Read your assigned Story Apply your assigned pattern Inspect the current Java component Preserve behavior Understand its existing behavior Explain design through UML + tests -
Deliverables 1 GitHub Tasks At least 3 native sub-issues linked
to the Story 2 Java refactoring Assigned component + pattern-specific classes 3 UML Update the original image at the same path 4 Quality JavaDoc + JUnit behavioral tests 5 Pull request Reference Story/Tasks; pass required checks -
Assignments — Observer & Strategy STORY GITHUB USERNAME PATTERN COMPONENT
#232 MKHLimkilde Observer LiDAR 3D display #233 sp4msvwnz Observer Activity display #234 an-prata Strategy Activity classifier #235 tphan56 Strategy Data availability monitor #238 Omarc2007 Strategy Message validator #240 dkguru27 Observer Eye tracking GUI #241 mars-rams Strategy Gaze statistics #243 srinityad Observer Robot diagnostics -
Assignments — Builder, Decorator & Factory STORY GITHUB USERNAME PATTERN
COMPONENT #236 ReeledWarrior14 Decorator Retrieve messages #237 Landon-McCaslin Builder Store messages #239 anthony-Soto Decorator Encrypt messages #242 matthewdaviii Builder Message input #244 sipactivism Factory Gather robot data -
Today’s lab Read Story, existing code, UML, and A03 guide
Create 3 (or more) native GitHub sub-issue Tasks 10 min Submit Story + Task links on Canvas -
Three Tasks: minimum structure TASKS related to Analyze & design
Pattern roles, affected classes/interfaces, original UML path TASKS related to Implement Refactoring steps, Java files, responsibilities, JavaDoc TASKS related to Verify & document JUnit behavioral cases, preserved behavior, UML review -
Before you open your PR ✓ Story and native Tasks
linked ✓ Assigned Java source updated ✓ Original UML image updated in place ✓ JUnit tests demonstrate behavior ✓ Class-level JavaDoc: @author and @version ✓ Maven + Story/Task + A03 checks pass -
Where to ind the instructions Repository github.com/CSC-Sandbox/3100-requirements Assignment overview ASSIGNMENTS.md
Testing and submission requirements docs/A03-TESTING.md f Today Lab : submit Story number + Task URLs in Canvas. -
CSC 3100 Fundamentals of Software Engineering Javier Gonzalez-Sanchez, Ph.D. [email protected]
Fall 2026 Copyright Notice. These slides are provided exclusively for educational use in CSC 3100 within the California State University system. Redistribution or use for any other purpose is prohibited without prior written permission.