jgs CSC 309 Software Engineering II Lecture 03: Software Metrics: Structural Quality Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.com Building 14 -227 Office Hours: By appointment
jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 | 8 A bad design smells. Robert C. Martin describes the following odors (among others): 1. Rigidity – The system is hard to change because every change forces many other changes. 2. Fragility – Changes cause the system to break in conceptually unrelated places. 3. Immobility – It’s hard to disentangle the system into reusable components. 4. Viscosity – Doing things right is harder than doing things wrong. 5. Opacity – It is hard to read and understand. It does not express its intent well. What could be measured or analyzed?
jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 | 10 § Express the portion of contained abstract types. § It is a value 0 to 1: 0 (only concrete classes) to 1 (only interfaces and abstract classes) Abstractness of a Package
jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 | 12 § Indicates whether the package is mainly used by other artifacts (stable – hard to change) or if it mainly depends on other artifacts (instable – changeable). § It is a value between 0 and 1: 0 only incoming dependencies to 1 (only outgoing dependencies) Instability of a Package
jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 | 16 § Distance: how far a package is away from the Main Sequence § D = A + I – 1 § Values -1 to 1 § Absolute Distance |D| Distance
jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 | 19 § Every dependency between modules should terminate on a module whose Instability metric is less than or equal to the depending module's Instability metric. § Every dependency between modules should terminate on a module whose Abstractness metric is greater than or equal to the depending module's Abstractness metric. Stable Dependency Principle
jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 | 26 public class Foo { Bar b= new Bar(new Car()); public Foo (Car c) { c.doIt(b); } public void m (Delta d) { d.action(b); } } public class System { public ... main ( ...) { Foo f = new Foo(); //... } } Question
jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 | 27 public class Foo { Bar b= new Bar(new Car()); public Foo (Car c) { c.doIt(b); } public void m (Delta d) { d.action(b); } } public class System { public ... main ( ...) { Foo f = new Foo(); //... } } Question • ISystem = • IFoo = • IBar • Any candidate for “painful” zone:
jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 | 31 Office Hours Tuesday and Thursday 3 - 5 pm But an appointment required Sent me an email – [email protected]
jgs CSC 309 Software Engineering II Lab 03: Structural Metrics Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.com Building 14 -227 Office Hours: By appointment
jgs CSC 309 Software Engineering II Javier Gonzalez-Sanchez, Ph.D. [email protected] Winter 2023 Copyright. These slides can only be used as study material for the class CSC308 at Cal Poly. They cannot be distributed or used for another purpose.