Slide 1

Slide 1 text

Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.info o ffi ce: 14 -227 CSC 307 Introduction to Software Engineering Lecture 11. Software Metrics

Slide 2

Slide 2 text

Reminder 2 Do not forget to submit your Individual proposal of What feature(s) you are implementing in your final project.

Slide 3

Slide 3 text

FRIDAY: Work on your project NO LECTURE / NO LAB MONDAY: CI/CD WEDNESDAY: CI/CD + Full Review FRIDAY: Final Exam Announcement 3

Slide 4

Slide 4 text

Code Metrics

Slide 5

Slide 5 text

Metrics Size LOC eLOC lLOC Complexity Cyclomatic Complexity Software Metrics 5

Slide 6

Slide 6 text

Software Metrics Size

Slide 7

Slide 7 text

Size Metrics • LOC – Lines of Code Metric. Including lines of a single br a ce or p a renthesis • LOC a re used to cre a te time a nd cost estim a tes. • LOC a re a tr a cking tool to me a sure the degree of progress on a module or project. • An experienced developer c a n g a ge a LOC estim a te b a sed upon knowledge of p a st productivity on projects. 7

Slide 8

Slide 8 text

Size Metrics • eLOC – e ff ective Lines of Code Metric. Only code st a tements • An e ff ective line of code or eLOC is the me a surement of a ll lines th a t a re not comments, bl a nks or st a nd a lone br a ces or p a renthesis. These c a n in f l a te LOC metrics by 20 to 40 percent. • This metric more closely represents the qu a ntity of work performed. 8

Slide 9

Slide 9 text

Size Metrics • lLOC – logic a l Lines of Code Metric. • These st a tements a re termin a ted with a semi-colon. • The control line for the "for" loop cont a in two semi-colons but a ccounts for only one semi colon. 9

Slide 10

Slide 10 text

Example 10

Slide 11

Slide 11 text

Test Yourselves

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

Software Metrics Complexity

Slide 20

Slide 20 text

Function Metrics • Cyclomatic Complexity. It is a quantitative measure of the number of linearly independent paths. • P a ths occur when "while,” "for,” "if,” "c a se," a nd "goto" keywords a ppe a r within the function. • If the source code cont a ined no control f low st a tements (condition a ls or decision points), the complexity would be 1 • If the code h a d one single-condition IF st a tement, there would be two p a ths through the code: one where the IF st a tement ev a lu a tes to TRUE a nd a nother one where it considers to be FALSE. • Two nested single-condition IFs, or one block with two conditions, would produce a complexity of 3. 20

Slide 21

Slide 21 text

Cyclomatic Complexity 21 CC = Edge - Node + 2 Or CC = ConditionalNodes + 1

Slide 22

Slide 22 text

Cyclomatic Complexity i = 0; n=4; while (i

Slide 23

Slide 23 text

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 Cyclomatic Complexity 23

Slide 24

Slide 24 text

Test Yourselves

Slide 25

Slide 25 text

Reminder 25 Which of the following projects is in a better stand?

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Structural Metrics Abstractness Instability

Slide 29

Slide 29 text

Is this a good design? 29

Slide 30

Slide 30 text

Is this a good design? 30

Slide 31

Slide 31 text

Abstractness of a Package • It is the degree to which a cl a ss or p a ck a ge emph a sizes a bstr a ction over concrete implement a tion • It is a v a lue 0 to 1: • For p a ck a ges, It is the r a tio of a bstr a ct cl a sses or interf a ces to the tot a l number of cl a sses within a p a ck a ge. • For cl a sses, It is 0 for a concrete cl a ss a nd 1 for a n interf a ce or a bstr a ct cl a sses 31

Slide 32

Slide 32 text

Instability • Indic a tes whether: ( a ) the item is m a inly used by others (st a ble – h a rd to ch a nge); or (b) it m a inly depends on other items (in-st a ble – ch a nge a ble). • It is a v a lue between 0 a nd 1: • 0 only incoming dependencies to • 1 (only outgoing dependencies). 32

Slide 33

Slide 33 text

Structural Metrics Distance

Slide 34

Slide 34 text

Distance • Dist a nce: how f a r a p a ck a ge is a w a y from the M a in Sequence • D = A + I – 1 • V a lues -1 to 1 • Absolute Dist a nce |D| 34

Slide 35

Slide 35 text

Distance 35 Abstract Concrete Stable Hard to Change Only incoming dependencies Unstable Changeable Only outgoing dependencies the m ain sequence Painful Useless 0 1 1 0 Instability Abstractness

Slide 36

Slide 36 text

project3.common.model project3.client.UI project3.server.controller

Slide 37

Slide 37 text

Test Yourselves

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

Questions 39

Slide 40

Slide 40 text

Lab 11 Software Metrics

Slide 41

Slide 41 text

Reminder 41 Calculate metrics for your Paint App 3.0 (or 2.0)

Slide 42

Slide 42 text

For each class: LOC eLOC lLOC Max CC A I D Draw the Distance Chart Reminder 42

Slide 43

Slide 43 text

Let’s Work 43

Slide 44

Slide 44 text

CSC 307 Introduction to Software Engineering Javier Gonzalez-Sanchez, Ph.D. [email protected] Summer 2024 Copyright. These slides can only be used as study material for the class CSC307 at Cal Poly. They cannot be distributed or used for another purpose.