Codequalität messen (enterJS 2014)

Preview:

DESCRIPTION

German talk. Hold at the enterJS 2014 in Cologne at 1st July 2014 (11:40 - 12:25) German description: Bei gesetzten Sprachen wie Java, C und PHP gehören Tools zum Messen von Kennzahlen zur Bestimmung der Qualität von Software zum Alltag. Für JavaScript ist das noch ein recht neuer Bereich. Besonders in modernen Webprojekten ist eine Charakterisierung der Software in Bezug auf Qualitätskennzahlen allerdings ein wichtiger Faktor hinsichtlich der Entwicklungs- und Ausführungsgeschwindigkeit sowie der Stabilität. Dieser Vortrag gibt eine Einführung in Metriken, wie sie sich erfassen und für die tägliche Arbeit nutzen lassen.

Citation preview

Codequalität messen EnterJS, 01. Juli 2014

Andy Grunwald

• Software Engineer bei @trivago

• Open Source

• @andygrunwald

• @PHPUGDus

• andygrunwald

Code | qualität | messen

–Helmut Balzert

„Unter Softwarequalität versteht man die Gesamtheit der Merkmale … eines Softwareprodukts, …, festgelegte oder

vorausgesetzte Erfordernisse zu erfüllen.“

(Software)-Metriken

Frontend

HTTP Requests

Navigation Timing

DOM Elemente

Browser Repaints

Backend

Request-Zeit

Cache-Miss / -Hits

Ressource-Zeit

Business-Logik

Source Code

Source Code

Functions count

Nested depth

Halstead

Maintainability index

LOC

Parameter count

Cyclomatic ComplexitynPath

Lint errors

CLOCLLOC

Your metric here

Source Code

Functions count

Nested depth

Halstead

Maintainability index

LOC

Parameter count

Cyclomatic ComplexitynPath

Lint errors

CLOCLLOC

Your metric here

_.isEmpty(e);

_.isEmpty(e);

• LOC: 19

_.isEmpty(e);

• LOC: 19

• CLOC: 2

_.isEmpty(e);

• LOC: 19

• CLOC: 2

• NCLOC: 17

_.isEmpty(e);

• LOC: 19

• CLOC: 2

• NCLOC: 17

• LLOC: 9

Source Code

Functions count

Nested depth

Halstead

Maintainability index

LOC

Parameter count

Cyclomatic ComplexitynPath

Lint errors

CLOCLLOC

Your metric here

Source Code

Functions count

Nested depth

Halstead

Maintainability index

LOC

Parameter count

Cyclomatic Complexity nPath

Lint errors

CLOCLLOC

Your metric here

Cyclomatic Complexity / McCabe

Anzahl von Entscheidungspunkteninnerhalb einer Funktion (if, switch, for,

while, …)

Cyclomatic Complexity: 4

nPath Complexity

Anzahl einzigartiger Ausführungspfade innerhalb einer Funktion

nPath Complexity: 4

Cyclomatic Complexity === nPath?

Cyclomatic Complexity: 4

nPath Complexity: 8

escomplex

complexity-report

plato

Esprima

yardstick

jsmeter

ScanJS

JSHint

jsprime

DoctorJs

JSWhiz

WALA

+

Sprach-Features

JavaScript ist eine dynamische Sprache

Referenzwerte / Schwellenwerte + Kontext

Referenzwerte / Schwellenwerte

Niedrig Normal Hoch Sehr hoch

Cyclomatic

Complexity1-4 5-7 8-10 >= 11

nPath / / / >= 200

Java (45 Projekte)

Metrik Niedrig Normal Hoch Sehr hoch

CYCLO/LOC 0.16 0.20 0.24 0.36

LOC/Methode 7 10 13 19.5

NOM/Class 4 7 10 15

C++ (37 Projekte)

Metrik Niedrig Normal Hoch Sehr hoch

CYCLO/LOC 0.20 0.25 0.30 0.45

LOC/Methode 5 10 16 24

NOM/Class 4 9 15 22.5

Metriken

Source Code

Functions count

Nested depth

Halstead

Maintainability index

LOC

Parameter count

Cyclomatic ComplexitynPath

Lint errors

CLOCLLOC

Your metric here

Verwendete Bilder

• „Ruler“ by Scott Akerman: https://www.flickr.com/photos/sterlic/4299631538/

• „the JavaScript Code“ by Dmitry Baranovskiy: https://www.flickr.com/photos/dmitry-baranovskiy/2378867408

• „Ignition“ by Zach Dischner: https://www.flickr.com/photos/zachd1_618/3489625168

• „Tools IMG_0171“ by OZinOH: https://www.flickr.com/photos/75905404@N00/7126146307

Verwendete Bilder

• „Danger & Skull, Legoland“ by bixentro: https://www.flickr.com/photos/bixentro/338433029

• „Baby“ by The Noun Project: http://thenounproject.com/term/baby/47/

• „Man“ by The Noun Project: http://thenounproject.com/term/man/2/

• „Sasquatch“ by Mike Wirth: http://thenounproject.com/term/sasquatch/2680/

Verwendete Bilder

• „Waking Up In Abbeyford Woods“ by Miles Wolstenholme: https://www.flickr.com/photos/oaktorphotography/14444806464

• „Danke 102/365“ by Dennis Skley: https://www.flickr.com/photos/dskley/13796815083/

• „Questions“ by Oberazzi: https://www.flickr.com/photos/oberazzi/318947873/in/photostream/

Zitate und Tabellen

• Helmut Balzert: Lehrbuch der Softwaretechnik. Band 2: Softwaremanagement, Software-Qualitätssicherung, Unternehmensmodellierung, Spektrum Akademischer Verlag, Heidelberg 1998, ISBN 3-8274-0065-1, S. 257

• Michele Lanza, Radu Marinescu: Object-Oriented Metrics in Practice: Using Software Metrics to Characterize, Evaluate, and Improve the Design of Object-Oriented Systems, Springer 2006, ISBN 3540244298

Recommended