Research Article

An Empirical Study on the Impact of Duplicate Code

Algorithm 1

A simple example of comparing two source files with diff (changed region is represented with identifier “c” like 3,4c3,4; deleted region is represented with identifier “d” like 7,8d6, added region is represented with identifier “a” like 11a10,11). The number before and after the identifier shows the correspond lines.
(a) before modification
 (1) A
  (2) B
  (3) line will be changed 1
  (4) line will be changed 2
  (5) C
  (6) D
  (7) line will be deleted 1
  (8) line will be deleted 2
  (9) E
  (10) F
  (11) G
  (12) H
(b) after modification
  (1) A
  (2) B
  (3) line changed 1
  (4) line changed 2
  (5) C
  (6) D
  (7) E
  (8) F
  (9) G
  (10) line added 1
  (11) line added 2
  (12) H
(c) diff output
3,4c3,4
< line will be changed 1
< line will be changed 2
---
>line changed 1
>line changed 2
7,8d6
<line will be deleted 1
<line will be deleted 2
11a10,11
>line added 1
>line added 2