Escolar Documentos
Profissional Documentos
Cultura Documentos
Dr. T. Jebarajan
There are four types of clones. They are divided into two
subgroups. First subgroup is based on text and the second
subgroup is based on function. Type-1, type-2, type-3 belongs
Code clones are also known as duplicated codes. They form to textual type and type-4 belongs to functional type. They are
a part of bad smells. Bad smells are the ones which affect the
listed below.
software system, thus resulting in poor quality. Some of the
bad smells are [8],
1) Textual Type:
Duplicated code
Long method
a) Type-1: Identical code fragments except for variations in
Large class
whitespace, layout and comments.
Useless method
Useless class
b) Type-2: Syntactically identical fragments except for
Though clones are considered as bad smells, they prove to
be useful in some cases. Beneficial functions developed by
skilled programmers can be made into a library function and
can use it within a software system wherever necessary.
Therefore, if code clones exist in software systems, they have to
be analyzed to check whether they are harmful or
beneficial. After analysis, harmful clones have to be
refactored and beneficial clones should be maintained.
287
2) Functional Type:
a) Type-4: Two or more code fragments that perform the same
computation but are implemented by
different syntactic
variants.
4.
5.
6.
7.
8.
Filtration
Extraction
Manual
Screening
Do the codes
contain Clones
/ Bad Smells ?
Data Mining
Technique
Rectify the
problematic codes
Regression
Testing
Refined Software
Module
288
C. Extraction
In this phase, the classes and methods are displayed with a
link to the source code of the module. When the user clicks on
a method or class the relevant codes which are highlighted is
displayed. Step (4) is executed here. Type-4 clones are
detected. Even bad smells can be detected in this stage.
D. Manual Screening
Here the displayed codes are examined for clones as well
as for bad smells. If any problematic codes are found they are
rectified. If there are clones with bug or clones which change
the operation of a function, they are considered as harmful
clones and removed. These types of clones cannot be rectified.
On the other hand, if there are clones which are reasonable
and beneficial, they are maintained in the module itself. The
clones detected in filtration and extraction stage, are well
analyzed here. In this level, steps (5), (6) and (7) are
performed.
E. Regression Testing
Regression means retesting the unchanged parts of the
application. Regression testing verifies whether the existing
functionality works as expected and the new changes have not
introduced any defect in functionality that was working before
this change. The software module undergoes this testing phase
only if modifications were made on that module. This testing
is performed in order to know whether the changes made
289
Now the extraction stage comes into the picture. Here too
both the classes and methods are displayed. The source code
of the classes and methods will be shown when clicked upon
it. The codes of the selected method or class alone will be
highlighted to make the programmer view instantly. This
phase helps in detecting Type-4 clones and bad smells.
290