measuring software: from data to actionable knowledge

166
Measuring Software: From Data to Actionable Knowledge 16 May 2015 International Workshop on Software Architecture and Metrics Radu Marinescu [email protected] @radu_marinescu

Upload: radu-marinescu

Post on 13-Aug-2015

216 views

Category:

Software


1 download

TRANSCRIPT

Page 1: Measuring Software: From Data to Actionable Knowledge

Measuring Software: From Data to Actionable Knowledge

16 May 2015

International Workshop on Software Architecture and Metrics

Radu Marinescu [email protected]

@radu_marinescu

Page 2: Measuring Software: From Data to Actionable Knowledge
Page 3: Measuring Software: From Data to Actionable Knowledge

Logo- culori

Culoare pentru o institu]ie unic\ - clar\, curat\, u[or de recunoscut - culoarea este elementul cel mai u[or de recunoscut, albastru indigo reflect\ personalitatea institu]iei de <nv\]\m>nt superior tehnic - ferm, puternic, dar introspectiv, valorizator. Este o combina]ie de albastru [i ro[u, <n care dominant este albastrul cu atributele sale introspective. Griul neutru pune <n valoare albastrul, accentu>nd valorile sale.

Page 4: Measuring Software: From Data to Actionable Knowledge

Logo- culori

Culoare pentru o institu]ie unic\ - clar\, curat\, u[or de recunoscut - culoarea este elementul cel mai u[or de recunoscut, albastru indigo reflect\ personalitatea institu]iei de <nv\]\m>nt superior tehnic - ferm, puternic, dar introspectiv, valorizator. Este o combina]ie de albastru [i ro[u, <n care dominant este albastrul cu atributele sale introspective. Griul neutru pune <n valoare albastrul, accentu>nd valorile sale.

Page 5: Measuring Software: From Data to Actionable Knowledge

Logo- culori

Culoare pentru o institu]ie unic\ - clar\, curat\, u[or de recunoscut - culoarea este elementul cel mai u[or de recunoscut, albastru indigo reflect\ personalitatea institu]iei de <nv\]\m>nt superior tehnic - ferm, puternic, dar introspectiv, valorizator. Este o combina]ie de albastru [i ro[u, <n care dominant este albastrul cu atributele sale introspective. Griul neutru pune <n valoare albastrul, accentu>nd valorile sale.

Page 6: Measuring Software: From Data to Actionable Knowledge

Logo- culori

Culoare pentru o institu]ie unic\ - clar\, curat\, u[or de recunoscut - culoarea este elementul cel mai u[or de recunoscut, albastru indigo reflect\ personalitatea institu]iei de <nv\]\m>nt superior tehnic - ferm, puternic, dar introspectiv, valorizator. Este o combina]ie de albastru [i ro[u, <n care dominant este albastrul cu atributele sale introspective. Griul neutru pune <n valoare albastrul, accentu>nd valorile sale.

Page 7: Measuring Software: From Data to Actionable Knowledge

Michele LanzaRadu Marinescu

Object-Oriented Metrics

in PracticeUsing Software Metrics to

Characterize, Evaluate, and Improve the Design of Object-Oriented Systems

Foreword by Stéphane Ducasse

Lanza · Marinescu

Object-O

riented M

etrics in Practice

Michele Lanza is an Assistant Professor at the University of Lugano, Switzer-land. His main research interests lie in software (re)engineering and software evo-lution with a special focus on software visualization and metrics. He is the creatorof CodeCrawler, a freely available language-independent software visualizationtool. His Ph.D. work won the Ernst Denert Software Engineering Award in 2003.Radu Marinescu is an Assistant Professor at the Politehnica University ofTimisoara, Romania. His research focus is on object-oriented design, reenginee-ring and quality assurance. He is the author of a suite of novel object-orientedmetrics and the main creator of iPlasma, an integrated and freely available tool-kit for Java and C++ projects. Several of his published research ideas have alreadybeen applied in the well-known “Borland Together Control Center” CASE tool.

783540 2442959

ISBN 3-540-24429-8

› springer.com

Object-Oriented Metrics inPracticeMetrics are paramount in every engineering discipline. However, due to its lackof rigor and its intrinsic complexity, software engineering is not considered aclassical engineering activity. Moreover, defining, understanding and applyingsoftware metrics often looks like an overly complex activity, recommended onlyto ‘trained professionals’. In general, if a software system is delivering theexpected functionality, only few people – if any – care about measuring the qua-lity of its internal structure. Consequently, software metrics are still regardedrather circumspectly by most software developers.

Lanza and Marinescu demystify the design metrics used to assess the size,quality and complexity of object-oriented software systems. Based on a novelapproach, backed by generally accepted semantics for metrics and by statisticalinformation from many industrial projects, they deduce a suite of metrics-basedpatterns for assessing the design of object-oriented software systems. Theyshow in detail how to identify design disharmonies in code, and how to deviseand apply remedies.

The combination of theoretically sound results and practically tested procedu-res and solution paths makes this book an ideal companion for professionalsoftware architects, developers and quality engineers. The pattern-oriented des-cription of disharmonies offers easy access to detecting shortcomings andapplying solutions to real problems.

Features and Benefits:

* comprehensive list of object-oriented disharmony patterns

* many reengineering strategies for poorly structured code

* brief introduction to software visualization

‘’This well-written book is an impor-tant piece of work that takes theseemingly forgotten art of object-oriented metrics to the next level interms of relevance and usefulness.’Richard C. Gronback,Chief Scientist, Borland SoftwareCorporation

13

1

1000+ reprinted 2010/2015

MIP ICSME’14

Page 8: Measuring Software: From Data to Actionable Knowledge

inFusion

Page 9: Measuring Software: From Data to Actionable Knowledge

inFusion

Page 10: Measuring Software: From Data to Actionable Knowledge

inFusion

Page 11: Measuring Software: From Data to Actionable Knowledge

inFusion

Page 12: Measuring Software: From Data to Actionable Knowledge

seentoo much…

I have

Page 13: Measuring Software: From Data to Actionable Knowledge

time & money wasted on…

Page 14: Measuring Software: From Data to Actionable Knowledge

“hide & seek” bug chasing

Page 15: Measuring Software: From Data to Actionable Knowledge

playing futile numbers games

Page 16: Measuring Software: From Data to Actionable Knowledge

code being thrown away

Page 17: Measuring Software: From Data to Actionable Knowledge

but also…

Page 18: Measuring Software: From Data to Actionable Knowledge

myriads of useless papers

Page 19: Measuring Software: From Data to Actionable Knowledge

tens of “mayfly” prototypes

Page 20: Measuring Software: From Data to Actionable Knowledge

a true story…

Page 21: Measuring Software: From Data to Actionable Knowledge
Page 22: Measuring Software: From Data to Actionable Knowledge

180.9

(12 subsystems)

(17 methods)

(3 subsystems)

NOW6 months ago

(1 class)

(22

(10 methods)

(32 classes)

(16 classes)

(28 classes)

(120 methods)

Page 23: Measuring Software: From Data to Actionable Knowledge
Page 24: Measuring Software: From Data to Actionable Knowledge

180.9

(12 subsystems)

(17 methods)

(3 subsystems)

NOW6 months ago

(1 class)

(22

(10 methods)

(32 classes)

(16 classes)

(28 classes)

(120 methods)

Page 25: Measuring Software: From Data to Actionable Knowledge

180.9

(12 subsystems)

(17 methods)

(3 subsystems)

NOW6 months ago

(1 class)

(22

(10 methods)

(32 classes)

(16 classes)

(28 classes)

(120 methods)

Page 26: Measuring Software: From Data to Actionable Knowledge

180.9

(12 subsystems)

(17 methods)

(3 subsystems)

NOW6 months ago

(1 class)

(22

(10 methods)

(32 classes)

(16 classes)

(28 classes)

(120 methods)

Page 27: Measuring Software: From Data to Actionable Knowledge

CYCLOMATIC COMPLEXITY

Page 28: Measuring Software: From Data to Actionable Knowledge

!This is not an isolated story

Page 29: Measuring Software: From Data to Actionable Knowledge
Page 30: Measuring Software: From Data to Actionable Knowledge

use of metrics(and other code analyses) in

Page 31: Measuring Software: From Data to Actionable Knowledge

use of metrics(and other code analyses) in

misuse

Page 32: Measuring Software: From Data to Actionable Knowledge

http://nemo.sonarqube.org/

Page 33: Measuring Software: From Data to Actionable Knowledge

12 Person-Years

http://nemo.sonarqube.org/

Page 34: Measuring Software: From Data to Actionable Knowledge

12 Person-Years

1 issues / 8 LOChttp://nemo.sonarqube.org/

Page 35: Measuring Software: From Data to Actionable Knowledge

12 Person-Years

1 issues / 8 LOC1 “key” issue / 140 LOChttp://nemo.sonarqube.org/

Page 36: Measuring Software: From Data to Actionable Knowledge

12 Person-Years

1 issues / 8 LOC1 “key” issue / 140 LOC

OMG! How is an “E”?!

http://nemo.sonarqube.org/

Page 37: Measuring Software: From Data to Actionable Knowledge

Picture from http://www.savvykidsofarkansas.com/event/the-boy-who-cried-wolf/

Page 38: Measuring Software: From Data to Actionable Knowledge

http://nemo.sonarqube.org/

Page 39: Measuring Software: From Data to Actionable Knowledge

The most efficient 7 weeks in the history of software development…

http://nemo.sonarqube.org/

Page 40: Measuring Software: From Data to Actionable Knowledge

The most efficient 7 weeks in the history of software development…

http://nemo.sonarqube.org/

Page 41: Measuring Software: From Data to Actionable Knowledge

The most efficient 7 weeks in the history of software development…

16.5 Person-Years of Technical Debt vanished!http://nemo.sonarqube.org/

Page 42: Measuring Software: From Data to Actionable Knowledge

The most efficient 7 weeks in the history of software development…

16.5 Person-Years of Technical Debt vanished!http://nemo.sonarqube.org/

Page 43: Measuring Software: From Data to Actionable Knowledge
Page 44: Measuring Software: From Data to Actionable Knowledge

Let’s zoom-in…

Page 45: Measuring Software: From Data to Actionable Knowledge

http://nemo.sonarqube.org/

Page 46: Measuring Software: From Data to Actionable Knowledge

http://nemo.sonarqube.org/

Page 47: Measuring Software: From Data to Actionable Knowledge

http://nemo.sonarqube.org/

Page 48: Measuring Software: From Data to Actionable Knowledge

http://nemo.sonarqube.org/

Page 49: Measuring Software: From Data to Actionable Knowledge

http://nemo.sonarqube.org/

are these separate problems?

Page 50: Measuring Software: From Data to Actionable Knowledge

http://nemo.sonarqube.org/

Page 51: Measuring Software: From Data to Actionable Knowledge

http://nemo.sonarqube.org/

Page 52: Measuring Software: From Data to Actionable Knowledge

who “authorized” these thresholds?

http://nemo.sonarqube.org/

Page 53: Measuring Software: From Data to Actionable Knowledge

http://nemo.sonarqube.org/

Page 54: Measuring Software: From Data to Actionable Knowledge

http://nemo.sonarqube.org/

Page 55: Measuring Software: From Data to Actionable Knowledge

reducing CYCLO takes only 1 min / branch ?

http://nemo.sonarqube.org/

Page 56: Measuring Software: From Data to Actionable Knowledge

reducing CYCLO takes only 1 min / branch ?

reducing CYCLO for class is easier (137’) than for methods (285’)

http://nemo.sonarqube.org/

Page 57: Measuring Software: From Data to Actionable Knowledge

http://nemo.sonarqube.org/

Page 58: Measuring Software: From Data to Actionable Knowledge

http://nemo.sonarqube.org/

Page 59: Measuring Software: From Data to Actionable Knowledge

http://nemo.sonarqube.org/

Page 60: Measuring Software: From Data to Actionable Knowledge

never knew it’s so easy to change a signature!

http://nemo.sonarqube.org/

Page 61: Measuring Software: From Data to Actionable Knowledge

but what if…

Page 62: Measuring Software: From Data to Actionable Knowledge

but what if…

Page 63: Measuring Software: From Data to Actionable Knowledge

http://nemo.sonarqube.org/

Page 64: Measuring Software: From Data to Actionable Knowledge

solving duplication does only depend on the number of blocks?

http://nemo.sonarqube.org/

Page 65: Measuring Software: From Data to Actionable Knowledge

…are these 2 cases equally easy?

Page 66: Measuring Software: From Data to Actionable Knowledge

Page 67: Measuring Software: From Data to Actionable Knowledge

Image from http://imgur.com/gallery/iWKad22

Page 68: Measuring Software: From Data to Actionable Knowledge

Let’s summarize…

Page 69: Measuring Software: From Data to Actionable Knowledge
Page 70: Measuring Software: From Data to Actionable Knowledge

1 Irrelevant Warnings

Page 71: Measuring Software: From Data to Actionable Knowledge

1 Irrelevant Warnings

2 Misleading Debt Quantification

Page 72: Measuring Software: From Data to Actionable Knowledge

1 Irrelevant Warnings

2 Misleading Debt Quantification

3 Toxic/Stupid Refactoring Advices

Page 73: Measuring Software: From Data to Actionable Knowledge

1 Irrelevant Warnings

2 Misleading Debt Quantification

3 Toxic/Stupid Refactoring Advices

4 Phony Thresholds

Page 74: Measuring Software: From Data to Actionable Knowledge

Why ?

Page 75: Measuring Software: From Data to Actionable Knowledge

Technical Debt

Page 76: Measuring Software: From Data to Actionable Knowledge

The first scary things was bugs

Page 77: Measuring Software: From Data to Actionable Knowledge

http://www.google.com/imgres?imgurl=http://micheltriana.com/wp-content/uploads/2010/12/

resharper-8x6.png&imgrefurl=http://micheltriana.com/2010/12/01/configuring-resharper-code-analysis/

&h=459&w=640&tbnid=MFJydOmaXXj3xM:&zoom=1&docid=e0dqbvDRdbGVSM&ei=xOEcVaXfOsiWaoa6gJAI&tbm=isch&client

=safari&ved=0CBwQMygAMAA

Page 78: Measuring Software: From Data to Actionable Knowledge

http://www.google.com/imgres?imgurl=http://micheltriana.com/wp-content/uploads/2010/12/

resharper-8x6.png&imgrefurl=http://micheltriana.com/2010/12/01/configuring-resharper-code-analysis/

&h=459&w=640&tbnid=MFJydOmaXXj3xM:&zoom=1&docid=e0dqbvDRdbGVSM&ei=xOEcVaXfOsiWaoa6gJAI&tbm=isch&client

=safari&ved=0CBwQMygAMAA

Page 79: Measuring Software: From Data to Actionable Knowledge
Page 80: Measuring Software: From Data to Actionable Knowledge
Page 81: Measuring Software: From Data to Actionable Knowledge
Page 82: Measuring Software: From Data to Actionable Knowledge
Page 83: Measuring Software: From Data to Actionable Knowledge

but then we realised…

Page 84: Measuring Software: From Data to Actionable Knowledge

Most maintenance effort goes into

understanding messy code

47%

19%

6%

28%

Testing DocumentingCoding Understanding

M. Ben-Menachem and G. S. Marliss. Software quality: Producing practical, consistent software. International Thomson Computer Press, 1997

Page 85: Measuring Software: From Data to Actionable Knowledge

Bugserror-prone

Page 86: Measuring Software: From Data to Actionable Knowledge

Bugs

Timehard to maintain

error-prone

Page 87: Measuring Software: From Data to Actionable Knowledge

… and bugs also usually hide in

messy code

Page 88: Measuring Software: From Data to Actionable Knowledge

Checkstyle

Page 89: Measuring Software: From Data to Actionable Knowledge

!We missed

an essential distinction

Page 90: Measuring Software: From Data to Actionable Knowledge

=

Page 91: Measuring Software: From Data to Actionable Knowledge

Strategic Flaws

Tactical Flaws

Execution Flaws

…system

…statements

…classes and functions

How do I design the…

Page 92: Measuring Software: From Data to Actionable Knowledge

Execution flaws Tactical flaws

Page 93: Measuring Software: From Data to Actionable Knowledge

Execution flaws Tactical flaws

Page 94: Measuring Software: From Data to Actionable Knowledge

Execution flaws Tactical flaws

Page 95: Measuring Software: From Data to Actionable Knowledge

Execution flaws Tactical flaws

Page 96: Measuring Software: From Data to Actionable Knowledge

Execution flaws Tactical flaws

Page 97: Measuring Software: From Data to Actionable Knowledge
Page 98: Measuring Software: From Data to Actionable Knowledge
Page 99: Measuring Software: From Data to Actionable Knowledge

PSA

Page 100: Measuring Software: From Data to Actionable Knowledge

PSA Gleason

Page 101: Measuring Software: From Data to Actionable Knowledge

PSA Gleason

Page 102: Measuring Software: From Data to Actionable Knowledge

PSA Gleason

Page 103: Measuring Software: From Data to Actionable Knowledge

?what about tactical problems

Page 104: Measuring Software: From Data to Actionable Knowledge

public class TarHeader{ /**

* The entry's name. */public StringBuffer name;/** * The entry's permission mode. */public int mode;/** * The entry's user id. */public int userId;/** * The entry's group id. */public int groupId;

}

Page 105: Measuring Software: From Data to Actionable Knowledge

public/**

* The entry's name. */

/** * The entry's permission mode. */

int/** * The entry's user id. */

/** * The entry's group id. */

int

}

public

public

public

public

Page 106: Measuring Software: From Data to Actionable Knowledge

public/**

* The entry's name. */

/** * The entry's permission mode. */

int/** * The entry's user id. */

/** * The entry's group id. */

int

}

public

public

public

publicDat

a

Class

Page 107: Measuring Software: From Data to Actionable Knowledge

public/**

* The entry's name. */

/** * The entry's permission mode. */

/** * The entry's user id. */

/** * The entry's group id. */

int

}

Page 108: Measuring Software: From Data to Actionable Knowledge

public/**

* The entry's name. */

/** * The entry's permission mode. */

/** * The entry's user id. */

/** * The entry's group id. */

int

}

private

private

private

private

Page 109: Measuring Software: From Data to Actionable Knowledge

public/**

* The entry's name. */

/** * The entry's permission mode. */

/** * The entry's user id. */

/** * The entry's group id. */

int

}

private

private

private

private

Encapsulate public data (in TarHeader)1

Page 110: Measuring Software: From Data to Actionable Knowledge

compile errors!

Page 111: Measuring Software: From Data to Actionable Knowledge

public class {

public void parseTarHeader( TarHeader hdr, byte[] header ){int offset = 0;hdr.name = TarHeader.parseName( header, offset,

TarHeader.NAMELEN );

offset += TarHeader.NAMELEN;hdr.mode = (int)TarHeader.parseOctal( header, offset,

TarHeader.MODELEN );

offset += TarHeader.MODELEN;

hdr.userId = (int)TarHeader.parseOctal( header, offset, TarHeader.UIDLEN );

offset += TarHeader.UIDLEN;

hdr.groupId = (int)TarHeader.parseOctal( header, offset, TarHeader.GIDLEN );}

TarEntry

Page 112: Measuring Software: From Data to Actionable Knowledge

public

public

hdr.TarHeader.

offset += TarHeader.hdr.

TarHeader.

offset += TarHeader.

hdr.TarHeader.

offset += TarHeader.

hdr.TarHeader}

TarEntry

TarHeader hdr

hdr.name

hdr.mode

hdr.userId

hdr.groupId

parseTarHeader

Page 113: Measuring Software: From Data to Actionable Knowledge

public

public

hdr.TarHeader.

offset += TarHeader.hdr.

TarHeader.

offset += TarHeader.

hdr.TarHeader.

offset += TarHeader.

hdr.TarHeader}

TarEntry

TarHeader hdr

hdr.name

hdr.mode

hdr.userId

hdr.groupId

parseTarHeader

Move the method (TarEntry > TarHeader)1

Page 114: Measuring Software: From Data to Actionable Knowledge

public

public

hdr.TarHeader.

offset += TarHeader.hdr.

TarHeader.

offset += TarHeader.

hdr.TarHeader.

offset += TarHeader.

hdr.TarHeader}

TarEntry

TarHeader hdr

hdr.name

hdr.mode

hdr.userId

hdr.groupId

parseTarHeader

Encapsulate public data (in TarHeader)2

Move the method (TarEntry > TarHeader)1

Page 115: Measuring Software: From Data to Actionable Knowledge

however …

Page 116: Measuring Software: From Data to Actionable Knowledge

public

public inthdr.

header, offset, TarHeader.

offset += TarHeader.

hdr.offset, TarHeader.

offset += TarHeader.

hdr.offset, TarHeader.

offset += TarHeader.

hdr.offset, TarHeader

} public

int

hdr.offset, TarHeader.

offset += TarHeader.

hdr.offset, TarHeader.

long

offset = TarHeader.getLongOctalBytes( size, outbuf, offset, TarHeader.

}

hdr.mode = (int)TarHeader.parseOctal( header,

hdr.mode = (int)TarHeader.parseOctal( header,

offset, TarHeader.MODELEN );

offset, TarHeader.MODELEN );

offset += TarHeader.MODELEN;

offset += TarHeader.MODELEN;

hdr.userId = (int)TarHeader.parseOctal( header,

hdr.userId = (int)TarHeader.parseOctal( header, offset, TarHeader.UIDLEN );

offset, TarHeader.UIDLEN );

parseTarHeader

writeEntryHeader

Page 117: Measuring Software: From Data to Actionable Knowledge

public

public inthdr.

header, offset, TarHeader.

offset += TarHeader.

hdr.offset, TarHeader.

offset += TarHeader.

hdr.offset, TarHeader.

offset += TarHeader.

hdr.offset, TarHeader

} public

int

hdr.offset, TarHeader.

offset += TarHeader.

hdr.offset, TarHeader.

long

offset = TarHeader.getLongOctalBytes( size, outbuf, offset, TarHeader.

}

hdr.mode = (int)TarHeader.parseOctal( header,

hdr.mode = (int)TarHeader.parseOctal( header,

offset, TarHeader.MODELEN );

offset, TarHeader.MODELEN );

offset += TarHeader.MODELEN;

offset += TarHeader.MODELEN;

hdr.userId = (int)TarHeader.parseOctal( header,

hdr.userId = (int)TarHeader.parseOctal( header, offset, TarHeader.UIDLEN );

offset, TarHeader.UIDLEN );

parseTarHeader

writeEntryHeader

Duplic

ated

Code

Page 118: Measuring Software: From Data to Actionable Knowledge

public

public inthdr.

header, offset, TarHeader.

offset += TarHeader.

hdr.offset, TarHeader.

offset += TarHeader.

hdr.offset, TarHeader.

offset += TarHeader.

hdr.offset, TarHeader

} public

int

hdr.offset, TarHeader.

offset += TarHeader.

hdr.offset, TarHeader.

long

offset = TarHeader.getLongOctalBytes( size, outbuf, offset, TarHeader.

}

hdr.mode

hdr.mode

offset, TarHeader.

offset, TarHeader.

offset += TarHeader.

offset += TarHeader.

hdr.userId

hdr.userIdoffset, TarHeader.

offset, TarHeader.

parseTarHeader

writeEntryHeader

Extract method (by factoring out the duplicated code)1

Page 119: Measuring Software: From Data to Actionable Knowledge

public

public inthdr.

header, offset, TarHeader.

offset += TarHeader.

hdr.offset, TarHeader.

offset += TarHeader.

hdr.offset, TarHeader.

offset += TarHeader.

hdr.offset, TarHeader

} public

int

hdr.offset, TarHeader.

offset += TarHeader.

hdr.offset, TarHeader.

long

offset = TarHeader.getLongOctalBytes( size, outbuf, offset, TarHeader.

}

hdr.mode

hdr.mode

offset, TarHeader.

offset, TarHeader.

offset += TarHeader.

offset += TarHeader.

hdr.userId

hdr.userIdoffset, TarHeader.

offset, TarHeader.

parseTarHeader

writeEntryHeader

Extract method (by factoring out the duplicated code)1

Move the newly created method (in TarHeader)2

Page 120: Measuring Software: From Data to Actionable Knowledge

public

public inthdr.

header, offset, TarHeader.

offset += TarHeader.

hdr.offset, TarHeader.

offset += TarHeader.

hdr.offset, TarHeader.

offset += TarHeader.

hdr.offset, TarHeader

} public

int

hdr.offset, TarHeader.

offset += TarHeader.

hdr.offset, TarHeader.

long

offset = TarHeader.getLongOctalBytes( size, outbuf, offset, TarHeader.

}

hdr.mode

hdr.mode

offset, TarHeader.

offset, TarHeader.

offset += TarHeader.

offset += TarHeader.

hdr.userId

hdr.userIdoffset, TarHeader.

offset, TarHeader.

parseTarHeader

writeEntryHeader

Extract method (by factoring out the duplicated code)1

Move the newly created method (in TarHeader)2

Encapsulate public data (in TarHeader)3

Page 121: Measuring Software: From Data to Actionable Knowledge

yet, there is an alternative solution…

Page 122: Measuring Software: From Data to Actionable Knowledge
Page 123: Measuring Software: From Data to Actionable Knowledge

Move data (TarHeader > TarEntry)1

Page 124: Measuring Software: From Data to Actionable Knowledge

Move data (TarHeader > TarEntry)1

Encapsulate public data (in TarEntry)2

Page 125: Measuring Software: From Data to Actionable Knowledge

vs.

Extract method(out of the duplicated code)1

Move the newly created method(in TarHeader)2

Encapsulate public data(in TarHeader)3

Move data(TarHeader > TarEntry)1

Encapsulate public data(in TarEntry)2

Page 126: Measuring Software: From Data to Actionable Knowledge

vs.

Which solution is best?

Extract method(out of the duplicated code)1

Move the newly created method(in TarHeader)2

Encapsulate public data(in TarHeader)3

Move data(TarHeader > TarEntry)1

Encapsulate public data(in TarEntry)2

Page 127: Measuring Software: From Data to Actionable Knowledge

Only the developer who knows the context

can decide!

Page 128: Measuring Software: From Data to Actionable Knowledge

?How to deal with

tactical flaws

Page 129: Measuring Software: From Data to Actionable Knowledge

start with

symptom indicators

Checkstyle

Page 130: Measuring Software: From Data to Actionable Knowledge

Lorenz, Kidd, 1994Chidamber, Kemerer, 1994

LOC - number of lines of code

CYCLO - cyclomatic complexity of a function NOF - number of functions

FANOUT - outgoing coupling

NOA - number of attributes

DIT - depth of inheritance tree

TCC - tight class cohesion

Page 131: Measuring Software: From Data to Actionable Knowledge

The problem is…

Page 132: Measuring Software: From Data to Actionable Knowledge

Image from pickywallpapers.com

Page 133: Measuring Software: From Data to Actionable Knowledge
Page 134: Measuring Software: From Data to Actionable Knowledge

!Tactical flaws must be treated as

first-class entities

Page 135: Measuring Software: From Data to Actionable Knowledge

!…and symptoms must be

aggregated

Page 136: Measuring Software: From Data to Actionable Knowledge

for example…

Page 137: Measuring Software: From Data to Actionable Knowledge

from S.Demeyer, S.Ducasse, O.Nierstrasz - Object-Oriented Reengineering Patterns, 2003

Page 138: Measuring Software: From Data to Actionable Knowledge

from S.Demeyer, S.Ducasse, O.Nierstrasz - Object-Oriented Reengineering Patterns, 2003

Page 139: Measuring Software: From Data to Actionable Knowledge

from S.Demeyer, S.Ducasse, O.Nierstrasz - Object-Oriented Reengineering Patterns, 2003

Page 140: Measuring Software: From Data to Actionable Knowledge

or another example…

Page 141: Measuring Software: From Data to Actionable Knowledge

God Classes use data from small data-classes, centralize the intelligence of the system, and do everything.

A.Riel, 1996

Page 142: Measuring Software: From Data to Actionable Knowledge

God Classes break encapsulation, and are complex, and are not cohesive.

A.Riel, 1996

Page 143: Measuring Software: From Data to Actionable Knowledge

ATFD > FEW

Class uses directly more than a

few attributes of other classes

WMC ≥ VERY HIGH

Functional complexity of the

class is very high

TCC < ONE THIRD

Class cohesion is low

AND GodClass

from M.Lanza, R.Marinescu - Object-Oriented Metrics in Practice, 2006

Page 144: Measuring Software: From Data to Actionable Knowledge

but there is

one more problem when dealing with metrics…

Page 145: Measuring Software: From Data to Actionable Knowledge

Thresholds

Page 146: Measuring Software: From Data to Actionable Knowledge

who “authorized” these thresholds?

Page 147: Measuring Software: From Data to Actionable Knowledge

Experts, right?

Image from http://www.dilbert.com

Page 148: Measuring Software: From Data to Actionable Knowledge
Page 149: Measuring Software: From Data to Actionable Knowledge

5 projects?!?! < 100 classes?!?!

Page 150: Measuring Software: From Data to Actionable Knowledge

Michele LanzaRadu Marinescu

Object-Oriented Metrics

in PracticeUsing Software Metrics to

Characterize, Evaluate, and Improve the Design of Object-Oriented Systems

Foreword by Stéphane Ducasse

Lanza · Marinescu

Ob

ject-Orien

ted

Metrics in

Practice

Michele Lanza is an Assistant Professor at the University of Lugano, Switzer-land. His main research interests lie in software (re)engineering and software evo-lution with a special focus on software visualization and metrics. He is the creatorof CodeCrawler, a freely available language-independent software visualizationtool. His Ph.D. work won the Ernst Denert Software Engineering Award in 2003.Radu Marinescu is an Assistant Professor at the Politehnica University ofTimisoara, Romania. His research focus is on object-oriented design, reenginee-ring and quality assurance. He is the author of a suite of novel object-orientedmetrics and the main creator of iPlasma, an integrated and freely available tool-kit for Java and C++ projects. Several of his published research ideas have alreadybeen applied in the well-known “Borland Together Control Center” CASE tool.

783540 2442959

ISBN 3-540-24429-8

› springer.com

Object-Oriented Metrics inPracticeMetrics are paramount in every engineering discipline. However, due to its lackof rigor and its intrinsic complexity, software engineering is not considered aclassical engineering activity. Moreover, defining, understanding and applyingsoftware metrics often looks like an overly complex activity, recommended onlyto ‘trained professionals’. In general, if a software system is delivering theexpected functionality, only few people – if any – care about measuring the qua-lity of its internal structure. Consequently, software metrics are still regardedrather circumspectly by most software developers.

Lanza and Marinescu demystify the design metrics used to assess the size,quality and complexity of object-oriented software systems. Based on a novelapproach, backed by generally accepted semantics for metrics and by statisticalinformation from many industrial projects, they deduce a suite of metrics-basedpatterns for assessing the design of object-oriented software systems. Theyshow in detail how to identify design disharmonies in code, and how to deviseand apply remedies.

The combination of theoretically sound results and practically tested procedu-res and solution paths makes this book an ideal companion for professionalsoftware architects, developers and quality engineers. The pattern-oriented des-cription of disharmonies offers easy access to detecting shortcomings andapplying solutions to real problems.

Features and Benefits:

* comprehensive list of object-oriented disharmony patterns

* many reengineering strategies for poorly structured code

* brief introduction to software visualization

‘’This well-written book is an impor-tant piece of work that takes theseemingly forgotten art of object-oriented metrics to the next level interms of relevance and usefulness.’Richard C. Gronback,Chief Scientist, Borland SoftwareCorporation

13

1

Page 151: Measuring Software: From Data to Actionable Knowledge

Michele LanzaRadu Marinescu

Object-Oriented Metrics

in PracticeUsing Software Metrics to

Characterize, Evaluate, and Improve the Design of Object-Oriented Systems

Foreword by Stéphane Ducasse

Lanza · Marinescu

Ob

ject-Orien

ted

Metrics in

Practice

Michele Lanza is an Assistant Professor at the University of Lugano, Switzer-land. His main research interests lie in software (re)engineering and software evo-lution with a special focus on software visualization and metrics. He is the creatorof CodeCrawler, a freely available language-independent software visualizationtool. His Ph.D. work won the Ernst Denert Software Engineering Award in 2003.Radu Marinescu is an Assistant Professor at the Politehnica University ofTimisoara, Romania. His research focus is on object-oriented design, reenginee-ring and quality assurance. He is the author of a suite of novel object-orientedmetrics and the main creator of iPlasma, an integrated and freely available tool-kit for Java and C++ projects. Several of his published research ideas have alreadybeen applied in the well-known “Borland Together Control Center” CASE tool.

783540 2442959

ISBN 3-540-24429-8

› springer.com

Object-Oriented Metrics inPracticeMetrics are paramount in every engineering discipline. However, due to its lackof rigor and its intrinsic complexity, software engineering is not considered aclassical engineering activity. Moreover, defining, understanding and applyingsoftware metrics often looks like an overly complex activity, recommended onlyto ‘trained professionals’. In general, if a software system is delivering theexpected functionality, only few people – if any – care about measuring the qua-lity of its internal structure. Consequently, software metrics are still regardedrather circumspectly by most software developers.

Lanza and Marinescu demystify the design metrics used to assess the size,quality and complexity of object-oriented software systems. Based on a novelapproach, backed by generally accepted semantics for metrics and by statisticalinformation from many industrial projects, they deduce a suite of metrics-basedpatterns for assessing the design of object-oriented software systems. Theyshow in detail how to identify design disharmonies in code, and how to deviseand apply remedies.

The combination of theoretically sound results and practically tested procedu-res and solution paths makes this book an ideal companion for professionalsoftware architects, developers and quality engineers. The pattern-oriented des-cription of disharmonies offers easy access to detecting shortcomings andapplying solutions to real problems.

Features and Benefits:

* comprehensive list of object-oriented disharmony patterns

* many reengineering strategies for poorly structured code

* brief introduction to software visualization

‘’This well-written book is an impor-tant piece of work that takes theseemingly forgotten art of object-oriented metrics to the next level interms of relevance and usefulness.’Richard C. Gronback,Chief Scientist, Borland SoftwareCorporation

13

1

37/45 projects…

Page 152: Measuring Software: From Data to Actionable Knowledge
Page 153: Measuring Software: From Data to Actionable Knowledge

4800 projects (SourceForge) 300.000.000 lines of code

Page 154: Measuring Software: From Data to Actionable Knowledge

4800 projects (SourceForge) 300.000.000 lines of code inFusion

Page 155: Measuring Software: From Data to Actionable Knowledge

4800 projects (SourceForge) 300.000.000 lines of code inFusion

Page 156: Measuring Software: From Data to Actionable Knowledge

Wrapping it up…

Page 157: Measuring Software: From Data to Actionable Knowledge

#1 Distinguish tactical flaws from execution flaws

Page 158: Measuring Software: From Data to Actionable Knowledge

#2 Don’t correct tactical flaws by fixing isolated symptoms

Page 159: Measuring Software: From Data to Actionable Knowledge

#3 Correcting tactical flaws requires exploration tools

Page 160: Measuring Software: From Data to Actionable Knowledge

#3 Correcting tactical flaws requires exploration tools

powerf

ul

Page 161: Measuring Software: From Data to Actionable Knowledge

Flaw Summary

Page 162: Measuring Software: From Data to Actionable Knowledge

Flaw Summary

Visualization

Metrics

Related flaws

Source Highlighter

Dependency Breakout

Page 163: Measuring Software: From Data to Actionable Knowledge

#4 Improve technical debt calculators

Page 164: Measuring Software: From Data to Actionable Knowledge

#5 Build massive collection of curated measurement data

Page 165: Measuring Software: From Data to Actionable Knowledge

“ ”A single arrow is easily broken, but not ten in a bundle.

Japanese proverb

Page 166: Measuring Software: From Data to Actionable Knowledge

Measuring Software: From Data to Actionable Knowledge

16 May 2015

International Workshop on Software Architecture and Metrics

Radu Marinescu [email protected]

@radu_marinescu