Skip to main navigation Skip to search Skip to main content

Code clone studies in JavaScript applications

  • Wai Ting Cheung

Student thesis: Master's thesis

Abstract

Code cloning is one of the active research areas in the software engineering literature. Specifically, previous literature conducted many empirical studies on code cloning and reported that 7% to 23% of the code in a typical software system has been cloned. However, as web technology was less dominant in the past, there was less awareness on code clones in dynamic languages and most studies are limited to static languages such as Java, C, and C++. In addition, from a software maintenance point of view, code clones carry important domain knowledge about the understandability and reusability of similar systems. Nevertheless, most previous studies did not consider different application domains such as standalone projects or web applications. As a result, very little is known about clones in dynamic languages such as JavaScript in different application domains. In this thesis, we report a large-scale clone detection experiment in a dynamic programming language, JavaScript, for different application domains, web pages and standalone projects. We found that unlike JavaScript standalone projects, JavaScript in web pages contains various symptoms that indicate bad maintainability including 46% of widely scattered clones and 57% of function-level clones. We also found that JavaScript applications contain 60% to 90% of consistent clones, and they are easily refactorable. Our findings suggest the need of simple module systems for refactoring JavaScript applications. We propose a refactoring approach to automatically extract modules in JavaScript applications by leveraging code clone analysis. We evaluated our approach on 29 JavaScript web pages and 27 JavaScript standalone projects by software quality and developers’ acceptability. Our experiment results show that our approach helps to improve the understandability by 1 – 20% and complexity by 1 – 35%, and developers have higher acceptability in the modules extracted by our approach.
Date of Award2013
Original languageEnglish
Awarding Institution
  • The Hong Kong University of Science and Technology

Cite this

'