12.07.2015 Views

A Metric for Software Readability - ArrestedComputing

A Metric for Software Readability - ArrestedComputing

A Metric for Software Readability - ArrestedComputing

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

A <strong>Metric</strong> <strong>for</strong><strong>Software</strong><strong>Readability</strong>Ray Buse ∙ Westley WeimerISSTA 2008


<strong>Readability</strong>“The quality that enables the observer to correctlyperceive the message”<strong>Metric</strong>s <strong>for</strong> Natural Language• Flesch-Kincaid Grade Level• Gunning-Fog Index• SMOG Index• Automated <strong>Readability</strong> Index2


<strong>Readability</strong> and <strong>Software</strong>Code maintenance = 70% of lifecycle cost.And most of maintenance ef<strong>for</strong>t is spent readingcode!But do we have any way to gain some level ofassurance in code readability?5


HypothesisEmploying a simple set of local features, we canderive, from a set of human judgments, an accuratemodel of readability <strong>for</strong> code.• To what extent do humans agree on codereadability?• We know readability is important, but can we createa predictive model of it?• What could such a model teach us?6


Outline• Acquiring Human <strong>Readability</strong> Judgments• Extracting a Model• Model Per<strong>for</strong>mance• Correlation with External Notions of <strong>Software</strong>Quality• <strong>Readability</strong> and the <strong>Software</strong> Lifecycle7


8Snippet Sniper Demo


Scoring Data11


Score Distribution12


Setup13


FeaturesWe choose “local” code features• Line length• Length of identifier names• Comment density• Blank lines• Presence of numbers• [and 20 others]14


Model Per<strong>for</strong>mance15


External Notions of Quality16


<strong>Software</strong> Lifecycle17


<strong>Software</strong> Lifecycle 218


ConclusionsWe can automatically judge readability about aswell as the “average” human canThis notion of readability shows significantcorrelation with:• Version Changes• The output of a bug finder• Self-reported program maturityWe may also learn more about software readabilityby looking at the predictive power of our model’sfeatures19


Questions?Questions?20

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!