The effects of refactoring on a web application's quality of code

Loading...
Thumbnail Image

URL

Journal Title

Journal ISSN

Volume Title

Perustieteiden korkeakoulu | Master's thesis

Department

Major/Subject

Mcode

SCI3042

Language

en

Pages

62 + 6

Series

Abstract

Refactoring in software development means the modification of source code without changing the software's external behavior. It's often done to improve the readability, maintainability, design, and/or structure of the code. It's considered one of the most important practices to improve a software's quality while preserving its behavior. Static code analysis is a method of program analysis to gain information about the quality of a program without executing it. This thesis conducts different static analyses to calculate and examine how refactoring has affected the JavaScript in a web application, Claus Customer, developed at Vediafi Oy. Scripts are implemented for running the analyses and parsing the results. The effects are presented as the change in Halstead complexity measures, the Maintainability index, and cyclomatic complexity. A comparative analysis for changes that were not refactorings was run as well. The study included two methods in gathering the refactoring data: manual, where the refactorings were hand-picked, and automatic, where they were automatically selected from the app's version history. It was concluded that the Manual analysis is more suitable for an isolated investigation of specific refactorings, and the Automatic analysis efficient in examining a large number of changes with little work. The results suggest that refactoring effects to code's quality cannot be generalized, as the effect on both file and function level was highly dependant on the type of the refactoring. New features, on the other hand, generally increased both file and function level complexity, although exceptions did exist.

Refaktorointi ohjelmistokehityksessä tarkoittaa ohjelman koodin muokkaamista ilman, että vaikuttaa ohjelman ulkoiseen toimivuuteen. Sen tarkoitus on usein parantaa koodin luettavuutta, ylläpidettävyyttä, muotoilua ja/tai rakennetta. Sitä pidetään yhtenä tärkeimmistä tavoista parantaa koodin laatua säilyttäen samalla sen ulkoisen toimivuuden. Staattinen ohjelma-analyysi on ohjelma-analyysin muoto, jossa ohjelman koodin laadusta saadaan tietoa ilman, että ohjelmaa ajetaan. Tässä työssä suoritetaan erityyppisiä staattisia analyysejä, jossa lasketaan ja tarkastellaan miten refaktorointi on vaikuttanut Claus Customer -web-sovelluksen JavaScript-koodiin. Työssä implementoitiin JavaScript ja Bash -ohjelmia analyysien automaattiseen ajamiseen ja tulosten muotoiluun. Refaktoroinnin efektit esitetään seuraavien metriikoiden muutoksena: Halsteadin kompleksisuusmetriikoiden, ylläpidettävyysindeksin ja syklomaattisen kompleksisuuden. Analyysi suoritettiin myös vertailun vuoksi koodimuutoksille, joissa ei ole refaktorointia. Tutkimuksessa käytettiin kahta metodia refaktorontimuutoksien keräämiseen: manuaalista, jossa muutokset kerättiin käsin, ja automaattista, jossa muutokset valittiin automaattisesti sovelluksen versiohistoriasta. Manuaalinen analyysi osoittautui sopivaksi eristettyyn tutkimukseen, jossa selvitetään tiettyjen refaktorointimuutoksien vaikutuksia. Automaattinen osottautui tehokkaaksi metodiksi suurten muutosjoukkojen tutkimisessa pienellä vaivalla. Tulokset viittaavat siihen, ettei refaktorointien vaikutuksia ohjelman koodin laatuun voi tulosten pohjalta yleistää, sillä muutoksen vaikutus sekä funktio- että tiedostotasolla oli merkittävästi riippuvainen refaktoroinnin tyypistä. Toisaalta uudet ominaisuudet yleisesti kasvattivat sekä funktio- että tiedostotason kompleksisuutta joitakin poikkeuksia lukuunottamatta.

Description

Supervisor

Haaranen, Lassi

Thesis advisor

Haaranen, Lassi
Nordström, Miika

Other note

Citation