<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Cjjacks2</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Cjjacks2"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Cjjacks2"/>
	<updated>2026-05-12T18:20:04Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29856</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 2 SN</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29856"/>
		<updated>2009-11-22T23:20:25Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Clone Detection and Clone Manipulation'''&lt;br /&gt;
&lt;br /&gt;
=='''Thesis'''==&lt;br /&gt;
The DRY principle says that a particular code fragment should not be repeated more than once in a program. But it happens. And when it does, it is good to be able to find the multiple code &amp;quot;clones.&amp;quot; A variety of tools have been designed for this, and some of them even allow joint editing of the clones. Survey the techniques for dealing with the problem, and compare the effectiveness with refactoring (e.g., Extract Method).&lt;br /&gt;
&lt;br /&gt;
=='''Code Cloning'''==&lt;br /&gt;
Often in computer systems whether small or large, code can become complex. As systems become larger and larger and more and more people work on the system there are often cases when the code becomes duplicated. Sometimes based on system architecture this is unavoidable. However often times replicated code can be avoided and should be as much as possible. It is always best approach to replace, reuse, and refactor code as much as possible.  &lt;br /&gt;
&lt;br /&gt;
There are times when code cloning is unavoidable. Factors such as design, security restrictions, rights of code, and class interaction can all be factors on why code cannot be manipulated in a way in which code cloning is not cannot be fixed. &lt;br /&gt;
&lt;br /&gt;
Clone Code Example [Baxter1998]&lt;br /&gt;
&lt;br /&gt;
  class Person&lt;br /&gt;
  {&lt;br /&gt;
    print 'name:'&lt;br /&gt;
    print firstname + &amp;quot; &amp;quot; + lastname&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
  class Doctor&lt;br /&gt;
  {&lt;br /&gt;
    print 'name:'&lt;br /&gt;
    print firstname + &amp;quot; &amp;quot; + lastname + &amp;quot; M.D.&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
== '''Clone Detection'''==&lt;br /&gt;
&lt;br /&gt;
Clone detection finds code in large software systems that has been replicated and modified by hand.&lt;br /&gt;
Remarkably, clone detection works because people copy conceptually identifiable blocks of code, and make only a few changes. This means the same syntax is detectably repeated. Each identified clone thus indicates the presence of a useful problem domain concept, and simultaneously provides an example implementation. Differences between the copies identify parameters or points of variation.[Baxter1998]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Clones can enhance a product line development in a number of ways:&lt;br /&gt;
 &lt;br /&gt;
*Removal of redundant code&lt;br /&gt;
*Lowering maintenance costs&lt;br /&gt;
*Identification of domain concepts for use in the present system or the next&lt;br /&gt;
*Identification of parametrized reusable implementations&lt;br /&gt;
*Sometimes reveal code bugs directly by inspection of parameter bindings with inconsistent actual or conceptual types&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is much hidden knowledge in open source software that can be valuable for improving software quality and productivity. For example, if we want to implement a new feature and know there exists code with similar functionalities in other projects, either reusing the existing code or simply using it for reference will likely shorten development time. Other examples include if a know software fault may occur within a particular context, we can quickly locate all similar defects. To uncover the hidden knowledge, a requisite step is to create an effective code search tool that can scale to the whole open source world, which contains hundreds of billions, even trillions of lines of code. An important aspect of code search is to find copied-and-pasted code or code that looks similar which is code cloning. [Baxter1995]&lt;br /&gt;
&lt;br /&gt;
Taken the approach that there is much to gain from code clone detection there is a need to compare the effectiveness of clone manipulation when a clone is found.&lt;br /&gt;
&lt;br /&gt;
==Clone Detection Techniques==&lt;br /&gt;
All Clone Techniques Cited From Burd2002&lt;br /&gt;
&lt;br /&gt;
===String Based ===&lt;br /&gt;
String based techniques use basic string transformation and comparison algorithms which makes them independent of programming languages. Techniques in this category differ in underlying string comparison algorithm. Comparing calculated signatures per line, is one possibility to identify for matching substrings. Line matching, which comes in two variants, is an alternative which is selected as representative for this category because it uses general string manipulations.&lt;br /&gt;
&lt;br /&gt;
===Simple Line Matching===&lt;br /&gt;
Simple Line Matching is the first variant of line matching in which both detection phases are straightforward. Only minor transformations using string manipulation operations, which can operate using no or very limited knowledge about possible language constructs, are applied. Typical transformations are the removal of empty lines and white spaces. During comparison all lines are compared with each other using a string matching algorithm. This results in a large search space which is usually reduced using hashing buckets. &lt;br /&gt;
&lt;br /&gt;
===Parameterized Line Matching===&lt;br /&gt;
Parameterized Line Matching is another variant of line matching which detects both identical as well as similar code fragments. The idea is that since identifier–names and literals are likely to change when cloning a code fragment, they can be considered as changeable parameters. Therefore, similar fragments which differ only in the naming of these parameters, are allowed.&lt;br /&gt;
&lt;br /&gt;
===Token Based===&lt;br /&gt;
Token based techniques use a more sophisticated transformation algorithm by constructing a token stream from the source code. The presence of such tokens makes it possible to use improved comparison algorithms. Next to parameterized matching with suffix trees, which acts as representative, we include in this category because it also transforms the source code in a token-structure which is afterwards matched. The latter tries to remove much more detail by summarizing non interesting code fragments.&lt;br /&gt;
&lt;br /&gt;
===Parameterized Matching===&lt;br /&gt;
Parameterized Matching With Suffix Trees consists of three consecutive steps manipulating a suffix tree as internal representation. In the first step, a lexical analyser passes over the source text transforming identifiers and literals in parameter symbols, while the typographical structure of each line is encoded in a non-parameter symbol. One symbol always refers to the same identifier, literal or structure. The result of this first step is a parameterized string or p-string.&lt;br /&gt;
Once the p-string is constructed, a criterion to decide whether two sequences in this p-string are a parameterized match or not is necessary. Two strings are a parameterized match if one can be transformed into the other by applying a one-to-one mapping renaming the parameter symbols. An additional encoding prev(S) of the parameter symbols helps us verifying this criterion. In this encoding, each first occurrence of a parameter symbol is replaced by a 0. All later occurrences are replaced by the distance since the previous occurrence of the same symbol. Thus, when two sequences have the same encoding, they are the same except for a systematic renaming of the parameter symbols.&lt;br /&gt;
After the lexical analysis, a data structure called a parameterized suffix tree (p-suffix tree) is built for the pstring. A p-suffix tree is a generalisation of the suffix tree data structure [16] which contains the prev()-encoding of every suffix of a P-string. Concatenating the labels of the arcs on the path from the root to the leaf yields the prev( )-encoding of one suffix. The use of a suffix tree allows a more efficient detection of maximal, parameterized matches.&lt;br /&gt;
&lt;br /&gt;
===Other Techniques===&lt;br /&gt;
AST-based techniques use parsers to first obtain a syntactical representation of the source code, typically an abstract syntax tree (AST). The clone detection algorithms then search for similar subtrees in this AST.&lt;br /&gt;
&lt;br /&gt;
PDG-based approaches  go one step further in obtaining a source code representation of high abstraction. Program dependence graphs (PDGs) contain information of semantically nature, such as control- and data flow of the program.&lt;br /&gt;
&lt;br /&gt;
Metrics-based techniques are related to hashing algorithms. For each fragment of a program the values of a number of metrics is calculated, which are subsequently used to find similar fragments.&lt;br /&gt;
&lt;br /&gt;
[[Image:CloneImage1.jpg]]&lt;br /&gt;
[[Image:CloneImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Clone Manipulation==&lt;br /&gt;
So what happens when clone code is? Once the clone detection tools have found code what techniques are available for the tools to solve the issues. The first step is to investigate why the clone code is there. &lt;br /&gt;
&lt;br /&gt;
*Several Questions need to be asked:&lt;br /&gt;
*What classes call the code?&lt;br /&gt;
*What functionality does the code provide?&lt;br /&gt;
*Who “owns” the code?&lt;br /&gt;
*How many systems depend on the code?&lt;br /&gt;
&lt;br /&gt;
Once these questions have been answered and it has been decided that this code cloning needs to be resolved then there are different techniques in solving the code clone issue. There are many tools out there to use for code detection and manipulation. Described below are the different tools researched and some information on the techniques used.[http://sel.ist.osaka-u.ac.jp/cdtools/index-e.html 1]&lt;br /&gt;
&lt;br /&gt;
==Clone Dr==&lt;br /&gt;
The CloneDR™ is built with the DMS/Software Reengineering Toolkit. This technology identifies not only exact, but near-miss duplicates in software systems and can be used on a wide variety of languages. Using compiler technology rather than string matching, it will find clones in spite of changed comments, white spaces, line breaks, case changes, different variable names and even different expressions in the clone body. It detects clones in code and/or data declarations. Detected clones can be filtered by size, and automatically or interactively removed. Clones can be removed by replacing them with equivalent preprocessor macros, type declarations, subroutine calls, or inlined subroutine calls (dependent on language and options), without changing the system functionality. The replacement is automatically generated from the detected clones.&lt;br /&gt;
&lt;br /&gt;
==SHINOBI==&lt;br /&gt;
SHINOBI is supported as an Add-In of Microsoft Visual Studio 2005. It automatically detects clones without the programmer's clear intention at the time of opening and editing source code, and constantly displays the detected clones on the view in IDE. SHINOBI displays the detected clones in order of the ranking f the similarity between the source code on the cursor and the detected clones, and the information in the CVS repository, such as message logs and committed dates of the source code that is detected clones.&lt;br /&gt;
&lt;br /&gt;
==CCFinderX==&lt;br /&gt;
CCFinder can be applied to huge source codes. From a source code with approximately a million lines, CCFinder can detect code clones within several minutes to several hours using a PC/AT compatible. By lexical analysis and transformation based on the syntax of the programming languages, CCFinder can extract code clones correctly from source files, even in cases where the names of variables have been changed. CCFinder can run for C/C++, Java, COBOL, Fortran, etc.&lt;br /&gt;
&lt;br /&gt;
*Multi-threading for multi-core CPU   &lt;br /&gt;
*AST-based preprocessing with an island-parser like parser.&lt;br /&gt;
*Search functions&lt;br /&gt;
*Users can adapt the tool to another programming languages or dialects.&lt;br /&gt;
*Analysis using metrics of code clone&lt;br /&gt;
*For interoperability with another tools, the tool can read/write data in tab separated values text format.&lt;br /&gt;
*Interactive analysis with multiple views of GUI front-end GemX.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
There are many different ways to go about code clone detection. Code clones can be detected on an exact match basis. Unfortunately, using exact match criteria for code clone detection may not be sufficient in all cases. For instance, a programmer may copy a particular piece of code, paste it to another location in the system and proceed to change the pasted code such that it remains syntactically similar to the original code, but not exactly similar. Thus, some form of near-exact clone detection must be employed. Parameterized matching (representative for the token-based approaches) provides a precise picture of a given piece of duplicated code and is robust against rename operations. Therefore it works best in combination with fine-grained refactoring tools that work on the level of statements. This is similar to how the refactoring methods of Extract Method, Move Behaviour, Close to Data, and Transform Conditionals into Polymorphism work.&lt;br /&gt;
Although there are different techniques use than the refactoring code methods the software tools seem to work nicely and continue to get better. The tools take a variety of techniques and make them work at an efficient level. As the technology advances the tools will become more and more useful to detect code clone issues.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
*[Baker1992] B.S. Baker, &amp;quot;A Program for Identifying Duplicated Code&amp;quot;, Proc. Computing Science and Statistics: 24th Symposium on the Interface, 24, pp. 49-57 Mar. 1992.&lt;br /&gt;
&lt;br /&gt;
*[Baker1995] B.S. Baker, &amp;quot;On finding Duplication and Near-Duplication in Large Software System&amp;quot;, Proc. Second IEEE Working Conf. on Reverse Eng., pp. 86-95 Jul. 1995.&lt;br /&gt;
&lt;br /&gt;
*[Balazinska1999] M. Balazinska, E. Merlo, M. Dagenais, B. Lague, and K.A. Kontogiannis, &amp;quot;Measuring Clone Based Reengineering Opportunities&amp;quot;, Proc. 6th IEEE Int'l Symposium on Software Metrics (METRICS '99), pp. 292-303, Boca Raton, Florida, Nov. 1999.&lt;br /&gt;
&lt;br /&gt;
*[Baxter1998] I.D. Baxter, A. Yahin, L. Moura, M. Sant'Anna, and L. Bier, &amp;quot;Clone Detection Using Abstract Syntax Trees&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '98, pp. 368-377, Bethesda, Maryland, Nov. 1998.&lt;br /&gt;
&lt;br /&gt;
*[Burd2002] Elizabeth Burd, John Bailey, &amp;quot;Evaluating Clone Detection Tools for Use during Preventative Maintenance,&amp;quot; Proc. 2nd IEEE International Workshop on Source Code Analysis and Manipulation (SCAM) 2002, pp. 36-43. Montreal, Canada, Oct. 2002.&lt;br /&gt;
&lt;br /&gt;
*[Ducasse1999] S. Ducasse, M. Rieger, and S. Demeyer. &amp;quot;A Language Independent Approach for Detecting Duplicated Code&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '99, pp. 109-118. Oxford, England. Aug. 1999.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*1 - [http://sel.ist.osaka-u.ac.jp/cdtools/index-e.html Code Clone Related Tools]&lt;br /&gt;
*2 - [http://research.cs.queensu.ca/home/cordy/Papers/RCK_SCP_Clones.pdf SCP Clones]&lt;br /&gt;
*3 - [http://www3.interscience.wiley.com/journal/112136397/abstract?CRETRY=1&amp;amp;SRETRY=0 Wiley Journal]&lt;br /&gt;
*4 - [http://www.computer.org/portal/web/csdl/doi/10.1109/ICSTW.2009.18 Mutation and Injection]&lt;br /&gt;
*5 - [http://www.cis.uab.edu/softcom/visual/ Visualizations of Code Clone Detection]&lt;br /&gt;
*6 - [http://www4.informatik.tu-muenchen.de/~juergens/publications/ICSE2009_FRD_0232_Juergens.pdf Code Clone Technical]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_22_SN&amp;diff=29855</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 22 SN</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_22_SN&amp;diff=29855"/>
		<updated>2009-11-22T23:19:50Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Clone Detection and Clone Manipulation'''&lt;br /&gt;
&lt;br /&gt;
=='''Thesis'''==&lt;br /&gt;
The DRY principle says that a particular code fragment should not be repeated more than once in a program. But it happens. And when it does, it is good to be able to find the multiple code &amp;quot;clones.&amp;quot; A variety of tools have been designed for this, and some of them even allow joint editing of the clones. Survey the techniques for dealing with the problem, and compare the effectiveness with refactoring (e.g., Extract Method).&lt;br /&gt;
&lt;br /&gt;
=='''Code Cloning'''==&lt;br /&gt;
Often in computer systems whether small or large, code can become complex. As systems become larger and larger and more and more people work on the system there are often cases when the code becomes duplicated. Sometimes based on system architecture this is unavoidable. However often times replicated code can be avoided and should be as much as possible. It is always best approach to replace, reuse, and refactor code as much as possible.  &lt;br /&gt;
&lt;br /&gt;
There are times when code cloning is unavoidable. Factors such as design, security restrictions, rights of code, and class interaction can all be factors on why code cannot be manipulated in a way in which code cloning is not cannot be fixed. &lt;br /&gt;
&lt;br /&gt;
Clone Code Example [Baxter1998]&lt;br /&gt;
&lt;br /&gt;
  class Person&lt;br /&gt;
  {&lt;br /&gt;
    print 'name:'&lt;br /&gt;
    print firstname + &amp;quot; &amp;quot; + lastname&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
  class Doctor&lt;br /&gt;
  {&lt;br /&gt;
    print 'name:'&lt;br /&gt;
    print firstname + &amp;quot; &amp;quot; + lastname + &amp;quot; M.D.&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
== '''Clone Detection'''==&lt;br /&gt;
&lt;br /&gt;
Clone detection finds code in large software systems that has been replicated and modified by hand.&lt;br /&gt;
Remarkably, clone detection works because people copy conceptually identifiable blocks of code, and make only a few changes. This means the same syntax is detectably repeated. Each identified clone thus indicates the presence of a useful problem domain concept, and simultaneously provides an example implementation. Differences between the copies identify parameters or points of variation.[Baxter1998]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Clones can enhance a product line development in a number of ways:&lt;br /&gt;
 &lt;br /&gt;
*Removal of redundant code&lt;br /&gt;
*Lowering maintenance costs&lt;br /&gt;
*Identification of domain concepts for use in the present system or the next&lt;br /&gt;
*Identification of parametrized reusable implementations&lt;br /&gt;
*Sometimes reveal code bugs directly by inspection of parameter bindings with inconsistent actual or conceptual types&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is much hidden knowledge in open source software that can be valuable for improving software quality and productivity. For example, if we want to implement a new feature and know there exists code with similar functionalities in other projects, either reusing the existing code or simply using it for reference will likely shorten development time. Other examples include if a know software fault may occur within a particular context, we can quickly locate all similar defects. To uncover the hidden knowledge, a requisite step is to create an effective code search tool that can scale to the whole open source world, which contains hundreds of billions, even trillions of lines of code. An important aspect of code search is to find copied-and-pasted code or code that looks similar which is code cloning. [Baxter1995]&lt;br /&gt;
&lt;br /&gt;
Taken the approach that there is much to gain from code clone detection there is a need to compare the effectiveness of clone manipulation when a clone is found.&lt;br /&gt;
&lt;br /&gt;
==Clone Detection Techniques==&lt;br /&gt;
All Clone Techniques Cited From Burd2002&lt;br /&gt;
&lt;br /&gt;
===String Based ===&lt;br /&gt;
String based techniques use basic string transformation and comparison algorithms which makes them independent of programming languages. Techniques in this category differ in underlying string comparison algorithm. Comparing calculated signatures per line, is one possibility to identify for matching substrings. Line matching, which comes in two variants, is an alternative which is selected as representative for this category because it uses general string manipulations.&lt;br /&gt;
&lt;br /&gt;
===Simple Line Matching===&lt;br /&gt;
Simple Line Matching is the first variant of line matching in which both detection phases are straightforward. Only minor transformations using string manipulation operations, which can operate using no or very limited knowledge about possible language constructs, are applied. Typical transformations are the removal of empty lines and white spaces. During comparison all lines are compared with each other using a string matching algorithm. This results in a large search space which is usually reduced using hashing buckets. &lt;br /&gt;
&lt;br /&gt;
===Parameterized Line Matching===&lt;br /&gt;
Parameterized Line Matching is another variant of line matching which detects both identical as well as similar code fragments. The idea is that since identifier–names and literals are likely to change when cloning a code fragment, they can be considered as changeable parameters. Therefore, similar fragments which differ only in the naming of these parameters, are allowed.&lt;br /&gt;
&lt;br /&gt;
===Token Based===&lt;br /&gt;
Token based techniques use a more sophisticated transformation algorithm by constructing a token stream from the source code. The presence of such tokens makes it possible to use improved comparison algorithms. Next to parameterized matching with suffix trees, which acts as representative, we include in this category because it also transforms the source code in a token-structure which is afterwards matched. The latter tries to remove much more detail by summarizing non interesting code fragments.&lt;br /&gt;
&lt;br /&gt;
===Parameterized Matching===&lt;br /&gt;
Parameterized Matching With Suffix Trees consists of three consecutive steps manipulating a suffix tree as internal representation. In the first step, a lexical analyser passes over the source text transforming identifiers and literals in parameter symbols, while the typographical structure of each line is encoded in a non-parameter symbol. One symbol always refers to the same identifier, literal or structure. The result of this first step is a parameterized string or p-string.&lt;br /&gt;
Once the p-string is constructed, a criterion to decide whether two sequences in this p-string are a parameterized match or not is necessary. Two strings are a parameterized match if one can be transformed into the other by applying a one-to-one mapping renaming the parameter symbols. An additional encoding prev(S) of the parameter symbols helps us verifying this criterion. In this encoding, each first occurrence of a parameter symbol is replaced by a 0. All later occurrences are replaced by the distance since the previous occurrence of the same symbol. Thus, when two sequences have the same encoding, they are the same except for a systematic renaming of the parameter symbols.&lt;br /&gt;
After the lexical analysis, a data structure called a parameterized suffix tree (p-suffix tree) is built for the pstring. A p-suffix tree is a generalisation of the suffix tree data structure [16] which contains the prev()-encoding of every suffix of a P-string. Concatenating the labels of the arcs on the path from the root to the leaf yields the prev( )-encoding of one suffix. The use of a suffix tree allows a more efficient detection of maximal, parameterized matches.&lt;br /&gt;
&lt;br /&gt;
===Other Techniques===&lt;br /&gt;
AST-based techniques use parsers to first obtain a syntactical representation of the source code, typically an abstract syntax tree (AST). The clone detection algorithms then search for similar subtrees in this AST.&lt;br /&gt;
&lt;br /&gt;
PDG-based approaches  go one step further in obtaining a source code representation of high abstraction. Program dependence graphs (PDGs) contain information of semantically nature, such as control- and data flow of the program.&lt;br /&gt;
&lt;br /&gt;
Metrics-based techniques are related to hashing algorithms. For each fragment of a program the values of a number of metrics is calculated, which are subsequently used to find similar fragments.&lt;br /&gt;
&lt;br /&gt;
[[Image:CloneImage1.jpg]]&lt;br /&gt;
[[Image:CloneImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Clone Manipulation==&lt;br /&gt;
So what happens when clone code is? Once the clone detection tools have found code what techniques are available for the tools to solve the issues. The first step is to investigate why the clone code is there. &lt;br /&gt;
&lt;br /&gt;
*Several Questions need to be asked:&lt;br /&gt;
*What classes call the code?&lt;br /&gt;
*What functionality does the code provide?&lt;br /&gt;
*Who “owns” the code?&lt;br /&gt;
*How many systems depend on the code?&lt;br /&gt;
&lt;br /&gt;
Once these questions have been answered and it has been decided that this code cloning needs to be resolved then there are different techniques in solving the code clone issue. There are many tools out there to use for code detection and manipulation. Described below are the different tools researched and some information on the techniques used.[http://sel.ist.osaka-u.ac.jp/cdtools/index-e.html 1]&lt;br /&gt;
&lt;br /&gt;
==Clone Dr==&lt;br /&gt;
The CloneDR™ is built with the DMS/Software Reengineering Toolkit. This technology identifies not only exact, but near-miss duplicates in software systems and can be used on a wide variety of languages. Using compiler technology rather than string matching, it will find clones in spite of changed comments, white spaces, line breaks, case changes, different variable names and even different expressions in the clone body. It detects clones in code and/or data declarations. Detected clones can be filtered by size, and automatically or interactively removed. Clones can be removed by replacing them with equivalent preprocessor macros, type declarations, subroutine calls, or inlined subroutine calls (dependent on language and options), without changing the system functionality. The replacement is automatically generated from the detected clones.&lt;br /&gt;
&lt;br /&gt;
==SHINOBI==&lt;br /&gt;
SHINOBI is supported as an Add-In of Microsoft Visual Studio 2005. It automatically detects clones without the programmer's clear intention at the time of opening and editing source code, and constantly displays the detected clones on the view in IDE. SHINOBI displays the detected clones in order of the ranking f the similarity between the source code on the cursor and the detected clones, and the information in the CVS repository, such as message logs and committed dates of the source code that is detected clones.&lt;br /&gt;
&lt;br /&gt;
==CCFinderX==&lt;br /&gt;
CCFinder can be applied to huge source codes. From a source code with approximately a million lines, CCFinder can detect code clones within several minutes to several hours using a PC/AT compatible. By lexical analysis and transformation based on the syntax of the programming languages, CCFinder can extract code clones correctly from source files, even in cases where the names of variables have been changed. CCFinder can run for C/C++, Java, COBOL, Fortran, etc.&lt;br /&gt;
&lt;br /&gt;
*Multi-threading for multi-core CPU   &lt;br /&gt;
*AST-based preprocessing with an island-parser like parser.&lt;br /&gt;
*Search functions&lt;br /&gt;
*Users can adapt the tool to another programming languages or dialects.&lt;br /&gt;
*Analysis using metrics of code clone&lt;br /&gt;
*For interoperability with another tools, the tool can read/write data in tab separated values text format.&lt;br /&gt;
*Interactive analysis with multiple views of GUI front-end GemX.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
There are many different ways to go about code clone detection. Code clones can be detected on an exact match basis. Unfortunately, using exact match criteria for code clone detection may not be sufficient in all cases. For instance, a programmer may copy a particular piece of code, paste it to another location in the system and proceed to change the pasted code such that it remains syntactically similar to the original code, but not exactly similar. Thus, some form of near-exact clone detection must be employed. Parameterized matching (representative for the token-based approaches) provides a precise picture of a given piece of duplicated code and is robust against rename operations. Therefore it works best in combination with fine-grained refactoring tools that work on the level of statements. This is similar to how the refactoring methods of Extract Method, Move Behaviour, Close to Data, and Transform Conditionals into Polymorphism work.&lt;br /&gt;
Although there are different techniques use than the refactoring code methods the software tools seem to work nicely and continue to get better. The tools take a variety of techniques and make them work at an efficient level. As the technology advances the tools will become more and more useful to detect code clone issues.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
*[Baker1992] B.S. Baker, &amp;quot;A Program for Identifying Duplicated Code&amp;quot;, Proc. Computing Science and Statistics: 24th Symposium on the Interface, 24, pp. 49-57 Mar. 1992.&lt;br /&gt;
&lt;br /&gt;
*[Baker1995] B.S. Baker, &amp;quot;On finding Duplication and Near-Duplication in Large Software System&amp;quot;, Proc. Second IEEE Working Conf. on Reverse Eng., pp. 86-95 Jul. 1995.&lt;br /&gt;
&lt;br /&gt;
*[Balazinska1999] M. Balazinska, E. Merlo, M. Dagenais, B. Lague, and K.A. Kontogiannis, &amp;quot;Measuring Clone Based Reengineering Opportunities&amp;quot;, Proc. 6th IEEE Int'l Symposium on Software Metrics (METRICS '99), pp. 292-303, Boca Raton, Florida, Nov. 1999.&lt;br /&gt;
&lt;br /&gt;
*[Baxter1998] I.D. Baxter, A. Yahin, L. Moura, M. Sant'Anna, and L. Bier, &amp;quot;Clone Detection Using Abstract Syntax Trees&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '98, pp. 368-377, Bethesda, Maryland, Nov. 1998.&lt;br /&gt;
&lt;br /&gt;
*[Burd2002] Elizabeth Burd, John Bailey, &amp;quot;Evaluating Clone Detection Tools for Use during Preventative Maintenance,&amp;quot; Proc. 2nd IEEE International Workshop on Source Code Analysis and Manipulation (SCAM) 2002, pp. 36-43. Montreal, Canada, Oct. 2002.&lt;br /&gt;
&lt;br /&gt;
*[Ducasse1999] S. Ducasse, M. Rieger, and S. Demeyer. &amp;quot;A Language Independent Approach for Detecting Duplicated Code&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '99, pp. 109-118. Oxford, England. Aug. 1999.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*1 - [http://sel.ist.osaka-u.ac.jp/cdtools/index-e.html Code Clone Related Tools]&lt;br /&gt;
*2 - [http://research.cs.queensu.ca/home/cordy/Papers/RCK_SCP_Clones.pdf SCP Clones]&lt;br /&gt;
*3 - [http://www3.interscience.wiley.com/journal/112136397/abstract?CRETRY=1&amp;amp;SRETRY=0 Wiley Journal]&lt;br /&gt;
*4 - [http://www.computer.org/portal/web/csdl/doi/10.1109/ICSTW.2009.18 Mutation and Injection]&lt;br /&gt;
*5 - [http://www.cis.uab.edu/softcom/visual/ Visualizations of Code Clone Detection]&lt;br /&gt;
*6 - [http://www4.informatik.tu-muenchen.de/~juergens/publications/ICSE2009_FRD_0232_Juergens.pdf Code Clone Technical]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_22_SN&amp;diff=29836</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 22 SN</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_22_SN&amp;diff=29836"/>
		<updated>2009-11-22T20:57:54Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Clone Detection and Clone Manipulation'''&lt;br /&gt;
&lt;br /&gt;
=='''Thesis'''==&lt;br /&gt;
The DRY principle says that a particular code fragment should not be repeated more than once in a program. But it happens. And when it does, it is good to be able to find the multiple code &amp;quot;clones.&amp;quot; A variety of tools have been designed for this, and some of them even allow joint editing of the clones. Survey the techniques for dealing with the problem, and compare the effectiveness with refactoring (e.g., Extract Method).&lt;br /&gt;
&lt;br /&gt;
=='''Code Cloning'''==&lt;br /&gt;
Often in computer systems whether small or large, code can become complex. As systems become larger and larger and more and more people work on the system there are often cases when the code becomes duplicated. Sometimes based on system architecture this is unavoidable. However often times replicated code can be avoided and should be as much as possible. It is always best approach to replace, reuse, and refactor code as much as possible.  &lt;br /&gt;
&lt;br /&gt;
There are times when code cloning is unavoidable. Factors such as design, security restrictions, rights of code, and class interaction can all be factors on why code cannot be manipulated in a way in which code cloning is not cannot be fixed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Clone Detection'''==&lt;br /&gt;
&lt;br /&gt;
Clone detection finds code in large software systems that has been replicated and modified by hand.&lt;br /&gt;
Remarkably, clone detection works because people copy conceptually identifiable blocks of code, and make only a few changes. This means the same syntax is detectably repeated. Each identified clone thus indicates the presence of a useful problem domain concept, and simultaneously provides an example implementation. Differences between the copies identify parameters or points of variation.[Baxter1998]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Clones can enhance a product line development in a number of ways:&lt;br /&gt;
 &lt;br /&gt;
*Removal of redundant code&lt;br /&gt;
*Lowering maintenance costs&lt;br /&gt;
*Identification of domain concepts for use in the present system or the next&lt;br /&gt;
*Identification of parametrized reusable implementations&lt;br /&gt;
*Sometimes reveal code bugs directly by inspection of parameter bindings with inconsistent actual or conceptual types&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is much hidden knowledge in open source software that can be valuable for improving software quality and productivity. For example, if we want to implement a new feature and know there exists code with similar functionalities in other projects, either reusing the existing code or simply using it for reference will likely shorten development time. Other examples include if a know software fault may occur within a particular context, we can quickly locate all similar defects. To uncover the hidden knowledge, a requisite step is to create an effective code search tool that can scale to the whole open source world, which contains hundreds of billions, even trillions of lines of code. An important aspect of code search is to find copied-and-pasted code or code that looks similar which is code cloning. [Baxter1995]&lt;br /&gt;
&lt;br /&gt;
Taken the approach that there is much to gain from code clone detection there is a need to compare the effectiveness of clone manipulation when a clone is found.&lt;br /&gt;
&lt;br /&gt;
==Clone Detection Techniques==&lt;br /&gt;
All Clone Techniques Cited From Burd2002&lt;br /&gt;
&lt;br /&gt;
===String Based ===&lt;br /&gt;
String based techniques use basic string transformation and comparison algorithms which makes them independent of programming languages. Techniques in this category differ in underlying string comparison algorithm. Comparing calculated signatures per line, is one possibility to identify for matching substrings. Line matching, which comes in two variants, is an alternative which is selected as representative for this category because it uses general string manipulations.&lt;br /&gt;
&lt;br /&gt;
===Simple Line Matching===&lt;br /&gt;
Simple Line Matching is the first variant of line matching in which both detection phases are straightforward. Only minor transformations using string manipulation operations, which can operate using no or very limited knowledge about possible language constructs, are applied. Typical transformations are the removal of empty lines and white spaces. During comparison all lines are compared with each other using a string matching algorithm. This results in a large search space which is usually reduced using hashing buckets. &lt;br /&gt;
&lt;br /&gt;
===Parameterized Line Matching===&lt;br /&gt;
Parameterized Line Matching is another variant of line matching which detects both identical as well as similar code fragments. The idea is that since identifier–names and literals are likely to change when cloning a code fragment, they can be considered as changeable parameters. Therefore, similar fragments which differ only in the naming of these parameters, are allowed.&lt;br /&gt;
&lt;br /&gt;
===Token Based===&lt;br /&gt;
Token based techniques use a more sophisticated transformation algorithm by constructing a token stream from the source code. The presence of such tokens makes it possible to use improved comparison algorithms. Next to parameterized matching with suffix trees, which acts as representative, we include in this category because it also transforms the source code in a token-structure which is afterwards matched. The latter tries to remove much more detail by summarizing non interesting code fragments.&lt;br /&gt;
&lt;br /&gt;
===Parameterized Matching===&lt;br /&gt;
Parameterized Matching With Suffix Trees consists of three consecutive steps manipulating a suffix tree as internal representation. In the first step, a lexical analyser passes over the source text transforming identifiers and literals in parameter symbols, while the typographical structure of each line is encoded in a non-parameter symbol. One symbol always refers to the same identifier, literal or structure. The result of this first step is a parameterized string or p-string.&lt;br /&gt;
Once the p-string is constructed, a criterion to decide whether two sequences in this p-string are a parameterized match or not is necessary. Two strings are a parameterized match if one can be transformed into the other by applying a one-to-one mapping renaming the parameter symbols. An additional encoding prev(S) of the parameter symbols helps us verifying this criterion. In this encoding, each first occurrence of a parameter symbol is replaced by a 0. All later occurrences are replaced by the distance since the previous occurrence of the same symbol. Thus, when two sequences have the same encoding, they are the same except for a systematic renaming of the parameter symbols.&lt;br /&gt;
After the lexical analysis, a data structure called a parameterized suffix tree (p-suffix tree) is built for the pstring. A p-suffix tree is a generalisation of the suffix tree data structure [16] which contains the prev()-encoding of every suffix of a P-string. Concatenating the labels of the arcs on the path from the root to the leaf yields the prev( )-encoding of one suffix. The use of a suffix tree allows a more efficient detection of maximal, parameterized matches.&lt;br /&gt;
&lt;br /&gt;
===Other Techniques===&lt;br /&gt;
AST-based techniques use parsers to first obtain a syntactical representation of the source code, typically an abstract syntax tree (AST). The clone detection algorithms then search for similar subtrees in this AST.&lt;br /&gt;
&lt;br /&gt;
PDG-based approaches  go one step further in obtaining a source code representation of high abstraction. Program dependence graphs (PDGs) contain information of semantically nature, such as control- and data flow of the program.&lt;br /&gt;
&lt;br /&gt;
Metrics-based techniques are related to hashing algorithms. For each fragment of a program the values of a number of metrics is calculated, which are subsequently used to find similar fragments.&lt;br /&gt;
&lt;br /&gt;
[[Image:CloneImage1.jpg]]&lt;br /&gt;
[[Image:CloneImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Clone Manipulation==&lt;br /&gt;
So what happens when clone code is? Once the clone detection tools have found code what techniques are available for the tools to solve the issues. The first step is to investigate why the clone code is there. &lt;br /&gt;
&lt;br /&gt;
*Several Questions need to be asked:&lt;br /&gt;
*What classes call the code?&lt;br /&gt;
*What functionality does the code provide?&lt;br /&gt;
*Who “owns” the code?&lt;br /&gt;
*How many systems depend on the code?&lt;br /&gt;
&lt;br /&gt;
Once these questions have been answered and it has been decided that this code cloning needs to be resolved then there are different techniques in solving the code clone issue. There are many tools out there to use for code detection and manipulation. Described below are the different tools researched and some information on the techniques used.[http://sel.ist.osaka-u.ac.jp/cdtools/index-e.html 1]&lt;br /&gt;
&lt;br /&gt;
==Clone Dr==&lt;br /&gt;
The CloneDR™ is built with the DMS/Software Reengineering Toolkit. This technology identifies not only exact, but near-miss duplicates in software systems and can be used on a wide variety of languages. Using compiler technology rather than string matching, it will find clones in spite of changed comments, white spaces, line breaks, case changes, different variable names and even different expressions in the clone body. It detects clones in code and/or data declarations. Detected clones can be filtered by size, and automatically or interactively removed. Clones can be removed by replacing them with equivalent preprocessor macros, type declarations, subroutine calls, or inlined subroutine calls (dependent on language and options), without changing the system functionality. The replacement is automatically generated from the detected clones.&lt;br /&gt;
&lt;br /&gt;
==SHINOBI==&lt;br /&gt;
SHINOBI is supported as an Add-In of Microsoft Visual Studio 2005. It automatically detects clones without the programmer's clear intention at the time of opening and editing source code, and constantly displays the detected clones on the view in IDE. SHINOBI displays the detected clones in order of the ranking f the similarity between the source code on the cursor and the detected clones, and the information in the CVS repository, such as message logs and committed dates of the source code that is detected clones.&lt;br /&gt;
&lt;br /&gt;
==CCFinderX==&lt;br /&gt;
CCFinder can be applied to huge source codes. From a source code with approximately a million lines, CCFinder can detect code clones within several minutes to several hours using a PC/AT compatible. By lexical analysis and transformation based on the syntax of the programming languages, CCFinder can extract code clones correctly from source files, even in cases where the names of variables have been changed. CCFinder can run for C/C++, Java, COBOL, Fortran, etc.&lt;br /&gt;
&lt;br /&gt;
*Multi-threading for multi-core CPU   &lt;br /&gt;
*AST-based preprocessing with an island-parser like parser.&lt;br /&gt;
*Search functions&lt;br /&gt;
*Users can adapt the tool to another programming languages or dialects.&lt;br /&gt;
*Analysis using metrics of code clone&lt;br /&gt;
*For interoperability with another tools, the tool can read/write data in tab separated values text format.&lt;br /&gt;
*Interactive analysis with multiple views of GUI front-end GemX.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
There are many different ways to go about code clone detection. Code clones can be detected on an exact match basis. Unfortunately, using exact match criteria for code clone detection may not be sufficient in all cases. For instance, a programmer may copy a particular piece of code, paste it to another location in the system and proceed to change the pasted code such that it remains syntactically similar to the original code, but not exactly similar. Thus, some form of near-exact clone detection must be employed. Parameterized matching (representative for the token-based approaches) provides a precise picture of a given piece of duplicated code and is robust against rename operations. Therefore it works best in combination with fine-grained refactoring tools that work on the level of statements. This is similar to how the refactoring methods of Extract Method, Move Behaviour, Close to Data, and Transform Conditionals into Polymorphism work.&lt;br /&gt;
Although there are different techniques use than the refactoring code methods the software tools seem to work nicely and continue to get better. The tools take a variety of techniques and make them work at an efficient level. As the technology advances the tools will become more and more useful to detect code clone issues.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
*[Baker1992] B.S. Baker, &amp;quot;A Program for Identifying Duplicated Code&amp;quot;, Proc. Computing Science and Statistics: 24th Symposium on the Interface, 24, pp. 49-57 Mar. 1992.&lt;br /&gt;
&lt;br /&gt;
*[Baker1995] B.S. Baker, &amp;quot;On finding Duplication and Near-Duplication in Large Software System&amp;quot;, Proc. Second IEEE Working Conf. on Reverse Eng., pp. 86-95 Jul. 1995.&lt;br /&gt;
&lt;br /&gt;
*[Balazinska1999] M. Balazinska, E. Merlo, M. Dagenais, B. Lague, and K.A. Kontogiannis, &amp;quot;Measuring Clone Based Reengineering Opportunities&amp;quot;, Proc. 6th IEEE Int'l Symposium on Software Metrics (METRICS '99), pp. 292-303, Boca Raton, Florida, Nov. 1999.&lt;br /&gt;
&lt;br /&gt;
*[Baxter1998] I.D. Baxter, A. Yahin, L. Moura, M. Sant'Anna, and L. Bier, &amp;quot;Clone Detection Using Abstract Syntax Trees&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '98, pp. 368-377, Bethesda, Maryland, Nov. 1998.&lt;br /&gt;
&lt;br /&gt;
*[Burd2002] Elizabeth Burd, John Bailey, &amp;quot;Evaluating Clone Detection Tools for Use during Preventative Maintenance,&amp;quot; Proc. 2nd IEEE International Workshop on Source Code Analysis and Manipulation (SCAM) 2002, pp. 36-43. Montreal, Canada, Oct. 2002.&lt;br /&gt;
&lt;br /&gt;
*[Ducasse1999] S. Ducasse, M. Rieger, and S. Demeyer. &amp;quot;A Language Independent Approach for Detecting Duplicated Code&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '99, pp. 109-118. Oxford, England. Aug. 1999.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*1 - [http://sel.ist.osaka-u.ac.jp/cdtools/index-e.html Code Clone Related Tools]&lt;br /&gt;
*2 - [http://research.cs.queensu.ca/home/cordy/Papers/RCK_SCP_Clones.pdf SCP Clones]&lt;br /&gt;
*3 - [http://www3.interscience.wiley.com/journal/112136397/abstract?CRETRY=1&amp;amp;SRETRY=0 Wiley Journal]&lt;br /&gt;
*4 - [http://www.computer.org/portal/web/csdl/doi/10.1109/ICSTW.2009.18 Mutation and Injection]&lt;br /&gt;
*5 - [http://www.cis.uab.edu/softcom/visual/ Visualizations of Code Clone Detection]&lt;br /&gt;
*6 - [http://www4.informatik.tu-muenchen.de/~juergens/publications/ICSE2009_FRD_0232_Juergens.pdf Code Clone Technical]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29833</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 2 SN</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29833"/>
		<updated>2009-11-22T20:39:24Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Clone Detection and Clone Manipulation'''&lt;br /&gt;
&lt;br /&gt;
=='''Thesis'''==&lt;br /&gt;
The DRY principle says that a particular code fragment should not be repeated more than once in a program. But it happens. And when it does, it is good to be able to find the multiple code &amp;quot;clones.&amp;quot; A variety of tools have been designed for this, and some of them even allow joint editing of the clones. Survey the techniques for dealing with the problem, and compare the effectiveness with refactoring (e.g., Extract Method).&lt;br /&gt;
&lt;br /&gt;
=='''Code Cloning'''==&lt;br /&gt;
Often in computer systems whether small or large, code can become complex. As systems become larger and larger and more and more people work on the system there are often cases when the code becomes duplicated. Sometimes based on system architecture this is unavoidable. However often times replicated code can be avoided and should be as much as possible. It is always best approach to replace, reuse, and refactor code as much as possible.  &lt;br /&gt;
&lt;br /&gt;
There are times when code cloning is unavoidable. Factors such as design, security restrictions, rights of code, and class interaction can all be factors on why code cannot be manipulated in a way in which code cloning is not cannot be fixed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Clone Detection'''==&lt;br /&gt;
&lt;br /&gt;
Clone detection finds code in large software systems that has been replicated and modified by hand.&lt;br /&gt;
Remarkably, clone detection works because people copy conceptually identifiable blocks of code, and make only a few changes. This means the same syntax is detectably repeated. Each identified clone thus indicates the presence of a useful problem domain concept, and simultaneously provides an example implementation. Differences between the copies identify parameters or points of variation.[Baxter1998]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Clones can enhance a product line development in a number of ways:&lt;br /&gt;
 &lt;br /&gt;
*Removal of redundant code&lt;br /&gt;
*Lowering maintenance costs&lt;br /&gt;
*Identification of domain concepts for use in the present system or the next&lt;br /&gt;
*Identification of parametrized reusable implementations&lt;br /&gt;
*Sometimes reveal code bugs directly by inspection of parameter bindings with inconsistent actual or conceptual types&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is much hidden knowledge in open source software that can be valuable for improving software quality and productivity. For example, if we want to implement a new feature and know there exists code with similar functionalities in other projects, either reusing the existing code or simply using it for reference will likely shorten development time. Other examples include if a know software fault may occur within a particular context, we can quickly locate all similar defects. To uncover the hidden knowledge, a requisite step is to create an effective code search tool that can scale to the whole open source world, which contains hundreds of billions, even trillions of lines of code. An important aspect of code search is to find copied-and-pasted code or code that looks similar which is code cloning. [Baxter1995]&lt;br /&gt;
&lt;br /&gt;
Taken the approach that there is much to gain from code clone detection there is a need to compare the effectiveness of clone manipulation when a clone is found.&lt;br /&gt;
&lt;br /&gt;
==Clone Detection Techniques==&lt;br /&gt;
All Clone Techniques Cited From Burd2002&lt;br /&gt;
&lt;br /&gt;
===String Based ===&lt;br /&gt;
String based techniques use basic string transformation and comparison algorithms which makes them independent of programming languages. Techniques in this category differ in underlying string comparison algorithm. Comparing calculated signatures per line, is one possibility to identify for matching substrings. Line matching, which comes in two variants, is an alternative which is selected as representative for this category because it uses general string manipulations.&lt;br /&gt;
&lt;br /&gt;
===Simple Line Matching===&lt;br /&gt;
Simple Line Matching is the first variant of line matching in which both detection phases are straightforward. Only minor transformations using string manipulation operations, which can operate using no or very limited knowledge about possible language constructs, are applied. Typical transformations are the removal of empty lines and white spaces. During comparison all lines are compared with each other using a string matching algorithm. This results in a large search space which is usually reduced using hashing buckets. &lt;br /&gt;
&lt;br /&gt;
===Parameterized Line Matching===&lt;br /&gt;
Parameterized Line Matching is another variant of line matching which detects both identical as well as similar code fragments. The idea is that since identifier–names and literals are likely to change when cloning a code fragment, they can be considered as changeable parameters. Therefore, similar fragments which differ only in the naming of these parameters, are allowed.&lt;br /&gt;
&lt;br /&gt;
===Token Based===&lt;br /&gt;
Token based techniques use a more sophisticated transformation algorithm by constructing a token stream from the source code. The presence of such tokens makes it possible to use improved comparison algorithms. Next to parameterized matching with suffix trees, which acts as representative, we include in this category because it also transforms the source code in a token-structure which is afterwards matched. The latter tries to remove much more detail by summarizing non interesting code fragments.&lt;br /&gt;
&lt;br /&gt;
===Parameterized Matching===&lt;br /&gt;
Parameterized Matching With Suffix Trees consists of three consecutive steps manipulating a suffix tree as internal representation. In the first step, a lexical analyser passes over the source text transforming identifiers and literals in parameter symbols, while the typographical structure of each line is encoded in a non-parameter symbol. One symbol always refers to the same identifier, literal or structure. The result of this first step is a parameterized string or p-string.&lt;br /&gt;
Once the p-string is constructed, a criterion to decide whether two sequences in this p-string are a parameterized match or not is necessary. Two strings are a parameterized match if one can be transformed into the other by applying a one-to-one mapping renaming the parameter symbols. An additional encoding prev(S) of the parameter symbols helps us verifying this criterion. In this encoding, each first occurrence of a parameter symbol is replaced by a 0. All later occurrences are replaced by the distance since the previous occurrence of the same symbol. Thus, when two sequences have the same encoding, they are the same except for a systematic renaming of the parameter symbols.&lt;br /&gt;
After the lexical analysis, a data structure called a parameterized suffix tree (p-suffix tree) is built for the pstring. A p-suffix tree is a generalisation of the suffix tree data structure [16] which contains the prev()-encoding of every suffix of a P-string. Concatenating the labels of the arcs on the path from the root to the leaf yields the prev( )-encoding of one suffix. The use of a suffix tree allows a more efficient detection of maximal, parameterized matches.&lt;br /&gt;
&lt;br /&gt;
===Other Techniques===&lt;br /&gt;
AST-based techniques use parsers to first obtain a syntactical representation of the source code, typically an abstract syntax tree (AST). The clone detection algorithms then search for similar subtrees in this AST.&lt;br /&gt;
&lt;br /&gt;
PDG-based approaches  go one step further in obtaining a source code representation of high abstraction. Program dependence graphs (PDGs) contain information of semantically nature, such as control- and data flow of the program.&lt;br /&gt;
&lt;br /&gt;
Metrics-based techniques are related to hashing algorithms. For each fragment of a program the values of a number of metrics is calculated, which are subsequently used to find similar fragments.&lt;br /&gt;
&lt;br /&gt;
[[Image:CloneImage1.jpg]]&lt;br /&gt;
[[Image:CloneImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Clone Manipulation==&lt;br /&gt;
So what happens when clone code is? Once the clone detection tools have found code what techniques are available for the tools to solve the issues. The first step is to investigate why the clone code is there. &lt;br /&gt;
&lt;br /&gt;
*Several Questions need to be asked:&lt;br /&gt;
*What classes call the code?&lt;br /&gt;
*What functionality does the code provide?&lt;br /&gt;
*Who “owns” the code?&lt;br /&gt;
*How many systems depend on the code?&lt;br /&gt;
&lt;br /&gt;
Once these questions have been answered and it has been decided that this code cloning needs to be resolved then there are different techniques in solving the code clone issue. There are many tools out there to use for code detection and manipulation. Described below are the different tools researched and some information on the techniques used.[http://sel.ist.osaka-u.ac.jp/cdtools/index-e.html 1]&lt;br /&gt;
&lt;br /&gt;
==Clone Dr==&lt;br /&gt;
The CloneDR™ is built with the DMS/Software Reengineering Toolkit. This technology identifies not only exact, but near-miss duplicates in software systems and can be used on a wide variety of languages. Using compiler technology rather than string matching, it will find clones in spite of changed comments, white spaces, line breaks, case changes, different variable names and even different expressions in the clone body. It detects clones in code and/or data declarations. Detected clones can be filtered by size, and automatically or interactively removed. Clones can be removed by replacing them with equivalent preprocessor macros, type declarations, subroutine calls, or inlined subroutine calls (dependent on language and options), without changing the system functionality. The replacement is automatically generated from the detected clones.&lt;br /&gt;
&lt;br /&gt;
==SHINOBI==&lt;br /&gt;
SHINOBI is supported as an Add-In of Microsoft Visual Studio 2005. It automatically detects clones without the programmer's clear intention at the time of opening and editing source code, and constantly displays the detected clones on the view in IDE. SHINOBI displays the detected clones in order of the ranking f the similarity between the source code on the cursor and the detected clones, and the information in the CVS repository, such as message logs and committed dates of the source code that is detected clones.&lt;br /&gt;
&lt;br /&gt;
==CCFinderX==&lt;br /&gt;
CCFinder can be applied to huge source codes. From a source code with approximately a million lines, CCFinder can detect code clones within several minutes to several hours using a PC/AT compatible. By lexical analysis and transformation based on the syntax of the programming languages, CCFinder can extract code clones correctly from source files, even in cases where the names of variables have been changed. CCFinder can run for C/C++, Java, COBOL, Fortran, etc.&lt;br /&gt;
&lt;br /&gt;
*Multi-threading for multi-core CPU   &lt;br /&gt;
*AST-based preprocessing with an island-parser like parser.&lt;br /&gt;
*Search functions&lt;br /&gt;
*Users can adapt the tool to another programming languages or dialects.&lt;br /&gt;
*Analysis using metrics of code clone&lt;br /&gt;
*For interoperability with another tools, the tool can read/write data in tab separated values text format.&lt;br /&gt;
*Interactive analysis with multiple views of GUI front-end GemX.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
There are many different ways to go about code clone detection. Code clones can be detected on an exact match basis. Unfortunately, using exact match criteria for code clone detection may not be sufficient in all cases. For instance, a programmer may copy a particular piece of code, paste it to another location in the system and proceed to change the pasted code such that it remains syntactically similar to the original code, but not exactly similar. Thus, some form of near-exact clone detection must be employed. Parameterized matching (representative for the token-based approaches) provides a precise picture of a given piece of duplicated code and is robust against rename operations. Therefore it works best in combination with fine-grained refactoring tools that work on the level of statements. This is similar to how the refactoring methods of Extract Method, Move Behaviour, Close to Data, and Transform Conditionals into Polymorphism work.&lt;br /&gt;
Although there are different techniques use than the refactoring code methods the software tools seem to work nicely and continue to get better. The tools take a variety of techniques and make them work at an efficient level. As the technology advances the tools will become more and more useful to detect code clone issues.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
*[Baker1992] B.S. Baker, &amp;quot;A Program for Identifying Duplicated Code&amp;quot;, Proc. Computing Science and Statistics: 24th Symposium on the Interface, 24, pp. 49-57 Mar. 1992.&lt;br /&gt;
&lt;br /&gt;
*[Baker1995] B.S. Baker, &amp;quot;On finding Duplication and Near-Duplication in Large Software System&amp;quot;, Proc. Second IEEE Working Conf. on Reverse Eng., pp. 86-95 Jul. 1995.&lt;br /&gt;
&lt;br /&gt;
*[Balazinska1999] M. Balazinska, E. Merlo, M. Dagenais, B. Lague, and K.A. Kontogiannis, &amp;quot;Measuring Clone Based Reengineering Opportunities&amp;quot;, Proc. 6th IEEE Int'l Symposium on Software Metrics (METRICS '99), pp. 292-303, Boca Raton, Florida, Nov. 1999.&lt;br /&gt;
&lt;br /&gt;
*[Baxter1998] I.D. Baxter, A. Yahin, L. Moura, M. Sant'Anna, and L. Bier, &amp;quot;Clone Detection Using Abstract Syntax Trees&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '98, pp. 368-377, Bethesda, Maryland, Nov. 1998.&lt;br /&gt;
&lt;br /&gt;
*[Burd2002] Elizabeth Burd, John Bailey, &amp;quot;Evaluating Clone Detection Tools for Use during Preventative Maintenance,&amp;quot; Proc. 2nd IEEE International Workshop on Source Code Analysis and Manipulation (SCAM) 2002, pp. 36-43. Montreal, Canada, Oct. 2002.&lt;br /&gt;
&lt;br /&gt;
*[Ducasse1999] S. Ducasse, M. Rieger, and S. Demeyer. &amp;quot;A Language Independent Approach for Detecting Duplicated Code&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '99, pp. 109-118. Oxford, England. Aug. 1999.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*1 - [http://sel.ist.osaka-u.ac.jp/cdtools/index-e.html Code Clone Related Tools]&lt;br /&gt;
*2 - [http://research.cs.queensu.ca/home/cordy/Papers/RCK_SCP_Clones.pdf SCP Clones]&lt;br /&gt;
*3 - [http://www3.interscience.wiley.com/journal/112136397/abstract?CRETRY=1&amp;amp;SRETRY=0 Wiley Journal]&lt;br /&gt;
*4 - [http://www.computer.org/portal/web/csdl/doi/10.1109/ICSTW.2009.18 Mutation and Injection]&lt;br /&gt;
*5 - [http://www.cis.uab.edu/softcom/visual/ Visualizations of Code Clone Detection]&lt;br /&gt;
*6 - [http://www4.informatik.tu-muenchen.de/~juergens/publications/ICSE2009_FRD_0232_Juergens.pdf Code Clone Technical]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:CloneImage2.jpg&amp;diff=29832</id>
		<title>File:CloneImage2.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:CloneImage2.jpg&amp;diff=29832"/>
		<updated>2009-11-22T20:38:21Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:CloneImage1.jpg&amp;diff=29831</id>
		<title>File:CloneImage1.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:CloneImage1.jpg&amp;diff=29831"/>
		<updated>2009-11-22T20:38:02Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29830</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 2 SN</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29830"/>
		<updated>2009-11-22T20:30:01Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Clone Detection and Clone Manipulation'''&lt;br /&gt;
&lt;br /&gt;
=='''Thesis'''==&lt;br /&gt;
The DRY principle says that a particular code fragment should not be repeated more than once in a program. But it happens. And when it does, it is good to be able to find the multiple code &amp;quot;clones.&amp;quot; A variety of tools have been designed for this, and some of them even allow joint editing of the clones. Survey the techniques for dealing with the problem, and compare the effectiveness with refactoring (e.g., Extract Method).&lt;br /&gt;
&lt;br /&gt;
=='''Code Cloning'''==&lt;br /&gt;
Often in computer systems whether small or large, code can become complex. As systems become larger and larger and more and more people work on the system there are often cases when the code becomes duplicated. Sometimes based on system architecture this is unavoidable. However often times replicated code can be avoided and should be as much as possible. It is always best approach to replace, reuse, and refactor code as much as possible.  &lt;br /&gt;
&lt;br /&gt;
There are times when code cloning is unavoidable. Factors such as design, security restrictions, rights of code, and class interaction can all be factors on why code cannot be manipulated in a way in which code cloning is not cannot be fixed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Clone Detection'''==&lt;br /&gt;
&lt;br /&gt;
Clone detection finds code in large software systems that has been replicated and modified by hand.&lt;br /&gt;
Remarkably, clone detection works because people copy conceptually identifiable blocks of code, and make only a few changes. This means the same syntax is detectably repeated. Each identified clone thus indicates the presence of a useful problem domain concept, and simultaneously provides an example implementation. Differences between the copies identify parameters or points of variation.[Baxter1998]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Clones can enhance a product line development in a number of ways:&lt;br /&gt;
 &lt;br /&gt;
*Removal of redundant code&lt;br /&gt;
*Lowering maintenance costs&lt;br /&gt;
*Identification of domain concepts for use in the present system or the next&lt;br /&gt;
*Identification of parametrized reusable implementations&lt;br /&gt;
*Sometimes reveal code bugs directly by inspection of parameter bindings with inconsistent actual or conceptual types&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is much hidden knowledge in open source software that can be valuable for improving software quality and productivity. For example, if we want to implement a new feature and know there exists code with similar functionalities in other projects, either reusing the existing code or simply using it for reference will likely shorten development time. Other examples include if a know software fault may occur within a particular context, we can quickly locate all similar defects. To uncover the hidden knowledge, a requisite step is to create an effective code search tool that can scale to the whole open source world, which contains hundreds of billions, even trillions of lines of code. An important aspect of code search is to find copied-and-pasted code or code that looks similar which is code cloning. [Baxter1995]&lt;br /&gt;
&lt;br /&gt;
Taken the approach that there is much to gain from code clone detection there is a need to compare the effectiveness of clone manipulation when a clone is found.&lt;br /&gt;
&lt;br /&gt;
==Clone Detection Techniques==&lt;br /&gt;
All Clone Techniques Cited From Burd2002&lt;br /&gt;
&lt;br /&gt;
===String Based ===&lt;br /&gt;
String based techniques use basic string transformation and comparison algorithms which makes them independent of programming languages. Techniques in this category differ in underlying string comparison algorithm. Comparing calculated signatures per line, is one possibility to identify for matching substrings. Line matching, which comes in two variants, is an alternative which is selected as representative for this category because it uses general string manipulations.&lt;br /&gt;
&lt;br /&gt;
===Simple Line Matching===&lt;br /&gt;
Simple Line Matching is the first variant of line matching in which both detection phases are straightforward. Only minor transformations using string manipulation operations, which can operate using no or very limited knowledge about possible language constructs, are applied. Typical transformations are the removal of empty lines and white spaces. During comparison all lines are compared with each other using a string matching algorithm. This results in a large search space which is usually reduced using hashing buckets. &lt;br /&gt;
&lt;br /&gt;
===Parameterized Line Matching===&lt;br /&gt;
Parameterized Line Matching is another variant of line matching which detects both identical as well as similar code fragments. The idea is that since identifier–names and literals are likely to change when cloning a code fragment, they can be considered as changeable parameters. Therefore, similar fragments which differ only in the naming of these parameters, are allowed.&lt;br /&gt;
&lt;br /&gt;
===Token Based===&lt;br /&gt;
Token based techniques use a more sophisticated transformation algorithm by constructing a token stream from the source code. The presence of such tokens makes it possible to use improved comparison algorithms. Next to parameterized matching with suffix trees, which acts as representative, we include in this category because it also transforms the source code in a token-structure which is afterwards matched. The latter tries to remove much more detail by summarizing non interesting code fragments.&lt;br /&gt;
&lt;br /&gt;
===Parameterized Matching===&lt;br /&gt;
Parameterized Matching With Suffix Trees consists of three consecutive steps manipulating a suffix tree as internal representation. In the first step, a lexical analyser passes over the source text transforming identifiers and literals in parameter symbols, while the typographical structure of each line is encoded in a non-parameter symbol. One symbol always refers to the same identifier, literal or structure. The result of this first step is a parameterized string or p-string.&lt;br /&gt;
Once the p-string is constructed, a criterion to decide whether two sequences in this p-string are a parameterized match or not is necessary. Two strings are a parameterized match if one can be transformed into the other by applying a one-to-one mapping renaming the parameter symbols. An additional encoding prev(S) of the parameter symbols helps us verifying this criterion. In this encoding, each first occurrence of a parameter symbol is replaced by a 0. All later occurrences are replaced by the distance since the previous occurrence of the same symbol. Thus, when two sequences have the same encoding, they are the same except for a systematic renaming of the parameter symbols.&lt;br /&gt;
After the lexical analysis, a data structure called a parameterized suffix tree (p-suffix tree) is built for the pstring. A p-suffix tree is a generalisation of the suffix tree data structure [16] which contains the prev()-encoding of every suffix of a P-string. Concatenating the labels of the arcs on the path from the root to the leaf yields the prev( )-encoding of one suffix. The use of a suffix tree allows a more efficient detection of maximal, parameterized matches.&lt;br /&gt;
&lt;br /&gt;
===Other Techniques===&lt;br /&gt;
AST-based techniques use parsers to first obtain a syntactical representation of the source code, typically an abstract syntax tree (AST). The clone detection algorithms then search for similar subtrees in this AST.&lt;br /&gt;
&lt;br /&gt;
PDG-based approaches  go one step further in obtaining a source code representation of high abstraction. Program dependence graphs (PDGs) contain information of semantically nature, such as control- and data flow of the program.&lt;br /&gt;
&lt;br /&gt;
Metrics-based techniques are related to hashing algorithms. For each fragment of a program the values of a number of metrics is calculated, which are subsequently used to find similar fragments.&lt;br /&gt;
&lt;br /&gt;
==Clone Manipulation==&lt;br /&gt;
So what happens when clone code is? Once the clone detection tools have found code what techniques are available for the tools to solve the issues. The first step is to investigate why the clone code is there. &lt;br /&gt;
&lt;br /&gt;
*Several Questions need to be asked:&lt;br /&gt;
*What classes call the code?&lt;br /&gt;
*What functionality does the code provide?&lt;br /&gt;
*Who “owns” the code?&lt;br /&gt;
*How many systems depend on the code?&lt;br /&gt;
&lt;br /&gt;
Once these questions have been answered and it has been decided that this code cloning needs to be resolved then there are different techniques in solving the code clone issue. There are many tools out there to use for code detection and manipulation. Described below are the different tools researched and some information on the techniques used.[http://sel.ist.osaka-u.ac.jp/cdtools/index-e.html 1]&lt;br /&gt;
&lt;br /&gt;
==Clone Dr==&lt;br /&gt;
The CloneDR™ is built with the DMS/Software Reengineering Toolkit. This technology identifies not only exact, but near-miss duplicates in software systems and can be used on a wide variety of languages. Using compiler technology rather than string matching, it will find clones in spite of changed comments, white spaces, line breaks, case changes, different variable names and even different expressions in the clone body. It detects clones in code and/or data declarations. Detected clones can be filtered by size, and automatically or interactively removed. Clones can be removed by replacing them with equivalent preprocessor macros, type declarations, subroutine calls, or inlined subroutine calls (dependent on language and options), without changing the system functionality. The replacement is automatically generated from the detected clones.&lt;br /&gt;
&lt;br /&gt;
==SHINOBI==&lt;br /&gt;
SHINOBI is supported as an Add-In of Microsoft Visual Studio 2005. It automatically detects clones without the programmer's clear intention at the time of opening and editing source code, and constantly displays the detected clones on the view in IDE. SHINOBI displays the detected clones in order of the ranking f the similarity between the source code on the cursor and the detected clones, and the information in the CVS repository, such as message logs and committed dates of the source code that is detected clones.&lt;br /&gt;
&lt;br /&gt;
==CCFinderX==&lt;br /&gt;
CCFinder can be applied to huge source codes. From a source code with approximately a million lines, CCFinder can detect code clones within several minutes to several hours using a PC/AT compatible. By lexical analysis and transformation based on the syntax of the programming languages, CCFinder can extract code clones correctly from source files, even in cases where the names of variables have been changed. CCFinder can run for C/C++, Java, COBOL, Fortran, etc.&lt;br /&gt;
&lt;br /&gt;
*Multi-threading for multi-core CPU   &lt;br /&gt;
*AST-based preprocessing with an island-parser like parser.&lt;br /&gt;
*Search functions&lt;br /&gt;
*Users can adapt the tool to another programming languages or dialects.&lt;br /&gt;
*Analysis using metrics of code clone&lt;br /&gt;
*For interoperability with another tools, the tool can read/write data in tab separated values text format.&lt;br /&gt;
*Interactive analysis with multiple views of GUI front-end GemX.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
There are many different ways to go about code clone detection. Code clones can be detected on an exact match basis. Unfortunately, using exact match criteria for code clone detection may not be sufficient in all cases. For instance, a programmer may copy a particular piece of code, paste it to another location in the system and proceed to change the pasted code such that it remains syntactically similar to the original code, but not exactly similar. Thus, some form of near-exact clone detection must be employed. Parameterized matching (representative for the token-based approaches) provides a precise picture of a given piece of duplicated code and is robust against rename operations. Therefore it works best in combination with fine-grained refactoring tools that work on the level of statements. This is similar to how the refactoring methods of Extract Method, Move Behaviour, Close to Data, and Transform Conditionals into Polymorphism work.&lt;br /&gt;
Although there are different techniques use than the refactoring code methods the software tools seem to work nicely and continue to get better. The tools take a variety of techniques and make them work at an efficient level. As the technology advances the tools will become more and more useful to detect code clone issues.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
*[Baker1992] B.S. Baker, &amp;quot;A Program for Identifying Duplicated Code&amp;quot;, Proc. Computing Science and Statistics: 24th Symposium on the Interface, 24, pp. 49-57 Mar. 1992.&lt;br /&gt;
&lt;br /&gt;
*[Baker1995] B.S. Baker, &amp;quot;On finding Duplication and Near-Duplication in Large Software System&amp;quot;, Proc. Second IEEE Working Conf. on Reverse Eng., pp. 86-95 Jul. 1995.&lt;br /&gt;
&lt;br /&gt;
*[Balazinska1999] M. Balazinska, E. Merlo, M. Dagenais, B. Lague, and K.A. Kontogiannis, &amp;quot;Measuring Clone Based Reengineering Opportunities&amp;quot;, Proc. 6th IEEE Int'l Symposium on Software Metrics (METRICS '99), pp. 292-303, Boca Raton, Florida, Nov. 1999.&lt;br /&gt;
&lt;br /&gt;
*[Baxter1998] I.D. Baxter, A. Yahin, L. Moura, M. Sant'Anna, and L. Bier, &amp;quot;Clone Detection Using Abstract Syntax Trees&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '98, pp. 368-377, Bethesda, Maryland, Nov. 1998.&lt;br /&gt;
&lt;br /&gt;
*[Burd2002] Elizabeth Burd, John Bailey, &amp;quot;Evaluating Clone Detection Tools for Use during Preventative Maintenance,&amp;quot; Proc. 2nd IEEE International Workshop on Source Code Analysis and Manipulation (SCAM) 2002, pp. 36-43. Montreal, Canada, Oct. 2002.&lt;br /&gt;
&lt;br /&gt;
*[Ducasse1999] S. Ducasse, M. Rieger, and S. Demeyer. &amp;quot;A Language Independent Approach for Detecting Duplicated Code&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '99, pp. 109-118. Oxford, England. Aug. 1999.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*1 - [http://sel.ist.osaka-u.ac.jp/cdtools/index-e.html Code Clone Related Tools]&lt;br /&gt;
*2 - [http://research.cs.queensu.ca/home/cordy/Papers/RCK_SCP_Clones.pdf SCP Clones]&lt;br /&gt;
*3 - [http://www3.interscience.wiley.com/journal/112136397/abstract?CRETRY=1&amp;amp;SRETRY=0 Wiley Journal]&lt;br /&gt;
*4 - [http://www.computer.org/portal/web/csdl/doi/10.1109/ICSTW.2009.18 Mutation and Injection]&lt;br /&gt;
*5 - [http://www.cis.uab.edu/softcom/visual/ Visualizations of Code Clone Detection]&lt;br /&gt;
*6 - [http://www4.informatik.tu-muenchen.de/~juergens/publications/ICSE2009_FRD_0232_Juergens.pdf Code Clone Technical]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29829</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 2 SN</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29829"/>
		<updated>2009-11-22T20:23:09Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Clone Detection and Clone Manipulation'''&lt;br /&gt;
&lt;br /&gt;
=='''Thesis'''==&lt;br /&gt;
The DRY principle says that a particular code fragment should not be repeated more than once in a program. But it happens. And when it does, it is good to be able to find the multiple code &amp;quot;clones.&amp;quot; A variety of tools have been designed for this, and some of them even allow joint editing of the clones. Survey the techniques for dealing with the problem, and compare the effectiveness with refactoring (e.g., Extract Method).&lt;br /&gt;
&lt;br /&gt;
=='''Code Cloning'''==&lt;br /&gt;
Often in computer systems whether small or large, code can become complex. As systems become larger and larger and more and more people work on the system there are often cases when the code becomes duplicated. Sometimes based on system architecture this is unavoidable. However often times replicated code can be avoided and should be as much as possible. It is always best approach to replace, reuse, and refactor code as much as possible.  &lt;br /&gt;
&lt;br /&gt;
There are times when code cloning is unavoidable. Factors such as design, security restrictions, rights of code, and class interaction can all be factors on why code cannot be manipulated in a way in which code cloning is not cannot be fixed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Clone Detection'''==&lt;br /&gt;
&lt;br /&gt;
Clone detection finds code in large software systems that has been replicated and modified by hand.&lt;br /&gt;
Remarkably, clone detection works because people copy conceptually identifiable blocks of code, and make only a few changes. This means the same syntax is detectably repeated. Each identified clone thus indicates the presence of a useful problem domain concept, and simultaneously provides an example implementation. Differences between the copies identify parameters or points of variation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Clones can enhance a product line development in a number of ways:&lt;br /&gt;
 &lt;br /&gt;
*Removal of redundant code&lt;br /&gt;
*Lowering maintenance costs&lt;br /&gt;
*Identification of domain concepts for use in the present system or the next&lt;br /&gt;
*Identification of parametrized reusable implementations&lt;br /&gt;
*Sometimes reveal code bugs directly by inspection of parameter bindings with inconsistent actual or conceptual types&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is much hidden knowledge in open source software that can be valuable for improving software quality and productivity. For example, if we want to implement a new feature and know there exists code with similar functionalities in other projects, either reusing the existing code or simply using it for reference will likely shorten development time. Other examples include if a know software fault may occur within a particular context, we can quickly locate all similar defects. To uncover the hidden knowledge, a requisite step is to create an effective code search tool that can scale to the whole open source world, which contains hundreds of billions, even trillions of lines of code. An important aspect of code search is to find copied-and-pasted code or code that looks similar which is code cloning. &lt;br /&gt;
&lt;br /&gt;
Taken the approach that there is much to gain from code clone detection there is a need to compare the effectiveness of clone manipulation when a clone is found.&lt;br /&gt;
&lt;br /&gt;
==Clone Detection Techniques==&lt;br /&gt;
&lt;br /&gt;
===String Based ===&lt;br /&gt;
String based techniques use basic string transformation and comparison algorithms which makes them independent of programming languages. Techniques in this category differ in underlying string comparison algorithm. Comparing calculated signatures per line, is one possibility to identify for matching substrings. Line matching, which comes in two variants, is an alternative which is selected as representative for this category because it uses general string manipulations.&lt;br /&gt;
&lt;br /&gt;
===Simple Line Matching===&lt;br /&gt;
Simple Line Matching is the first variant of line matching in which both detection phases are straightforward. Only minor transformations using string manipulation operations, which can operate using no or very limited knowledge about possible language constructs, are applied. Typical transformations are the removal of empty lines and white spaces. During comparison all lines are compared with each other using a string matching algorithm. This results in a large search space which is usually reduced using hashing buckets. &lt;br /&gt;
&lt;br /&gt;
===Parameterized Line Matching===&lt;br /&gt;
Parameterized Line Matching is another variant of line matching which detects both identical as well as similar code fragments. The idea is that since identifier–names and literals are likely to change when cloning a code fragment, they can be considered as changeable parameters. Therefore, similar fragments which differ only in the naming of these parameters, are allowed.&lt;br /&gt;
&lt;br /&gt;
===Token Based===&lt;br /&gt;
Token based techniques use a more sophisticated transformation algorithm by constructing a token stream from the source code. The presence of such tokens makes it possible to use improved comparison algorithms. Next to parameterized matching with suffix trees, which acts as representative, we include in this category because it also transforms the source code in a token-structure which is afterwards matched. The latter tries to remove much more detail by summarizing non interesting code fragments.&lt;br /&gt;
&lt;br /&gt;
===Parameterized Matching===&lt;br /&gt;
Parameterized Matching With Suffix Trees consists of three consecutive steps manipulating a suffix tree as internal representation. In the first step, a lexical analyser passes over the source text transforming identifiers and literals in parameter symbols, while the typographical structure of each line is encoded in a non-parameter symbol. One symbol always refers to the same identifier, literal or structure. The result of this first step is a parameterized string or p-string.&lt;br /&gt;
Once the p-string is constructed, a criterion to decide whether two sequences in this p-string are a parameterized match or not is necessary. Two strings are a parameterized match if one can be transformed into the other by applying a one-to-one mapping renaming the parameter symbols. An additional encoding prev(S) of the parameter symbols helps us verifying this criterion. In this encoding, each first occurrence of a parameter symbol is replaced by a 0. All later occurrences are replaced by the distance since the previous occurrence of the same symbol. Thus, when two sequences have the same encoding, they are the same except for a systematic renaming of the parameter symbols.&lt;br /&gt;
After the lexical analysis, a data structure called a parameterized suffix tree (p-suffix tree) is built for the pstring. A p-suffix tree is a generalisation of the suffix tree data structure [16] which contains the prev()-encoding of every suffix of a P-string. Concatenating the labels of the arcs on the path from the root to the leaf yields the prev( )-encoding of one suffix. The use of a suffix tree allows a more efficient detection of maximal, parameterized matches.&lt;br /&gt;
&lt;br /&gt;
===Other Techniques===&lt;br /&gt;
AST-based techniques use parsers to first obtain a syntactical representation of the source code, typically an abstract syntax tree (AST). The clone detection algorithms then search for similar subtrees in this AST.&lt;br /&gt;
&lt;br /&gt;
PDG-based approaches  go one step further in obtaining a source code representation of high abstraction. Program dependence graphs (PDGs) contain information of semantically nature, such as control- and data flow of the program.&lt;br /&gt;
&lt;br /&gt;
Metrics-based techniques are related to hashing algorithms. For each fragment of a program the values of a number of metrics is calculated, which are subsequently used to find similar fragments.&lt;br /&gt;
&lt;br /&gt;
==Clone Manipulation==&lt;br /&gt;
So what happens when clone code is? Once the clone detection tools have found code what techniques are available for the tools to solve the issues. The first step is to investigate why the clone code is there. &lt;br /&gt;
&lt;br /&gt;
*Several Questions need to be asked:&lt;br /&gt;
*What classes call the code?&lt;br /&gt;
*What functionality does the code provide?&lt;br /&gt;
*Who “owns” the code?&lt;br /&gt;
*How many systems depend on the code?&lt;br /&gt;
&lt;br /&gt;
Once these questions have been answered and it has been decided that this code cloning needs to be resolved then there are different techniques in solving the code clone issue. There are many tools out there to use for code detection and manipulation. Described below are the different tools researched and some information on the techniques used.[http://sel.ist.osaka-u.ac.jp/cdtools/index-e.html 1]&lt;br /&gt;
&lt;br /&gt;
==Clone Dr==&lt;br /&gt;
The CloneDR™ is built with the DMS/Software Reengineering Toolkit. This technology identifies not only exact, but near-miss duplicates in software systems and can be used on a wide variety of languages. Using compiler technology rather than string matching, it will find clones in spite of changed comments, white spaces, line breaks, case changes, different variable names and even different expressions in the clone body. It detects clones in code and/or data declarations. Detected clones can be filtered by size, and automatically or interactively removed. Clones can be removed by replacing them with equivalent preprocessor macros, type declarations, subroutine calls, or inlined subroutine calls (dependent on language and options), without changing the system functionality. The replacement is automatically generated from the detected clones.&lt;br /&gt;
&lt;br /&gt;
==SHINOBI==&lt;br /&gt;
SHINOBI is supported as an Add-In of Microsoft Visual Studio 2005. It automatically detects clones without the programmer's clear intention at the time of opening and editing source code, and constantly displays the detected clones on the view in IDE. SHINOBI displays the detected clones in order of the ranking f the similarity between the source code on the cursor and the detected clones, and the information in the CVS repository, such as message logs and committed dates of the source code that is detected clones.&lt;br /&gt;
&lt;br /&gt;
==CCFinderX==&lt;br /&gt;
CCFinder can be applied to huge source codes. From a source code with approximately a million lines, CCFinder can detect code clones within several minutes to several hours using a PC/AT compatible. By lexical analysis and transformation based on the syntax of the programming languages, CCFinder can extract code clones correctly from source files, even in cases where the names of variables have been changed. CCFinder can run for C/C++, Java, COBOL, Fortran, etc.&lt;br /&gt;
&lt;br /&gt;
*Multi-threading for multi-core CPU   &lt;br /&gt;
*AST-based preprocessing with an island-parser like parser.&lt;br /&gt;
*Search functions&lt;br /&gt;
*Users can adapt the tool to another programming languages or dialects.&lt;br /&gt;
*Analysis using metrics of code clone&lt;br /&gt;
*For interoperability with another tools, the tool can read/write data in tab separated values text format.&lt;br /&gt;
*Interactive analysis with multiple views of GUI front-end GemX.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
There are many different ways to go about code clone detection. Code clones can be detected on an exact match basis. Unfortunately, using exact match criteria for code clone detection may not be sufficient in all cases. For instance, a programmer may copy a particular piece of code, paste it to another location in the system and proceed to change the pasted code such that it remains syntactically similar to the original code, but not exactly similar. Thus, some form of near-exact clone detection must be employed. Parameterized matching (representative for the token-based approaches) provides a precise picture of a given piece of duplicated code and is robust against rename operations. Therefore it works best in combination with fine-grained refactoring tools that work on the level of statements. This is similar to how the refactoring methods of Extract Method, Move Behaviour, Close to Data, and Transform Conditionals into Polymorphism work.&lt;br /&gt;
Although there are different techniques use than the refactoring code methods the software tools seem to work nicely and continue to get better. The tools take a variety of techniques and make them work at an efficient level. As the technology advances the tools will become more and more useful to detect code clone issues.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
*[Baker1992] B.S. Baker, &amp;quot;A Program for Identifying Duplicated Code&amp;quot;, Proc. Computing Science and Statistics: 24th Symposium on the Interface, 24, pp. 49-57 Mar. 1992.&lt;br /&gt;
&lt;br /&gt;
*[Baker1995] B.S. Baker, &amp;quot;On finding Duplication and Near-Duplication in Large Software System&amp;quot;, Proc. Second IEEE Working Conf. on Reverse Eng., pp. 86-95 Jul. 1995.&lt;br /&gt;
&lt;br /&gt;
*[Balazinska1999] M. Balazinska, E. Merlo, M. Dagenais, B. Lague, and K.A. Kontogiannis, &amp;quot;Measuring Clone Based Reengineering Opportunities&amp;quot;, Proc. 6th IEEE Int'l Symposium on Software Metrics (METRICS '99), pp. 292-303, Boca Raton, Florida, Nov. 1999.&lt;br /&gt;
&lt;br /&gt;
*[Baxter1998] I.D. Baxter, A. Yahin, L. Moura, M. Sant'Anna, and L. Bier, &amp;quot;Clone Detection Using Abstract Syntax Trees&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '98, pp. 368-377, Bethesda, Maryland, Nov. 1998.&lt;br /&gt;
&lt;br /&gt;
*[Burd2002] Elizabeth Burd, John Bailey, &amp;quot;Evaluating Clone Detection Tools for Use during Preventative Maintenance,&amp;quot; Proc. 2nd IEEE International Workshop on Source Code Analysis and Manipulation (SCAM) 2002, pp. 36-43. Montreal, Canada, Oct. 2002.&lt;br /&gt;
&lt;br /&gt;
*[Ducasse1999] S. Ducasse, M. Rieger, and S. Demeyer. &amp;quot;A Language Independent Approach for Detecting Duplicated Code&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '99, pp. 109-118. Oxford, England. Aug. 1999.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*1 - [http://sel.ist.osaka-u.ac.jp/cdtools/index-e.html Code Clone Related Tools]&lt;br /&gt;
*2 - [http://research.cs.queensu.ca/home/cordy/Papers/RCK_SCP_Clones.pdf SCP Clones]&lt;br /&gt;
*3 - [http://www3.interscience.wiley.com/journal/112136397/abstract?CRETRY=1&amp;amp;SRETRY=0 Wiley Journal]&lt;br /&gt;
*4 - [http://www.computer.org/portal/web/csdl/doi/10.1109/ICSTW.2009.18 Mutation and Injection]&lt;br /&gt;
*5 - [http://www.cis.uab.edu/softcom/visual/ Visualizations of Code Clone Detection]&lt;br /&gt;
*6 - [http://www4.informatik.tu-muenchen.de/~juergens/publications/ICSE2009_FRD_0232_Juergens.pdf Code Clone Technical]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29828</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 2 SN</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29828"/>
		<updated>2009-11-22T20:19:21Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Clone Detection and Clone Manipulation'''&lt;br /&gt;
&lt;br /&gt;
=='''Thesis'''==&lt;br /&gt;
The DRY principle says that a particular code fragment should not be repeated more than once in a program. But it happens. And when it does, it is good to be able to find the multiple code &amp;quot;clones.&amp;quot; A variety of tools have been designed for this, and some of them even allow joint editing of the clones. Survey the techniques for dealing with the problem, and compare the effectiveness with refactoring (e.g., Extract Method).&lt;br /&gt;
&lt;br /&gt;
=='''Code Cloning'''==&lt;br /&gt;
Often in computer systems whether small or large, code can become complex. As systems become larger and larger and more and more people work on the system there are often cases when the code becomes duplicated. Sometimes based on system architecture this is unavoidable. However often times replicated code can be avoided and should be as much as possible. It is always best approach to replace, reuse, and refactor code as much as possible.  &lt;br /&gt;
&lt;br /&gt;
There are times when code cloning is unavoidable. Factors such as design, security restrictions, rights of code, and class interaction can all be factors on why code cannot be manipulated in a way in which code cloning is not cannot be fixed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Clone Detection'''==&lt;br /&gt;
&lt;br /&gt;
Clone detection finds code in large software systems that has been replicated and modified by hand.&lt;br /&gt;
Remarkably, clone detection works because people copy conceptually identifiable blocks of code, and make only a few changes. This means the same syntax is detectably repeated. Each identified clone thus indicates the presence of a useful problem domain concept, and simultaneously provides an example implementation. Differences between the copies identify parameters or points of variation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Clones can enhance a product line development in a number of ways:&lt;br /&gt;
 &lt;br /&gt;
*Removal of redundant code&lt;br /&gt;
*Lowering maintenance costs&lt;br /&gt;
*Identification of domain concepts for use in the present system or the next&lt;br /&gt;
*Identification of parametrized reusable implementations&lt;br /&gt;
*Sometimes reveal code bugs directly by inspection of parameter bindings with inconsistent actual or conceptual types&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is much hidden knowledge in open source software that can be valuable for improving software quality and productivity. For example, if we want to implement a new feature and know there exists code with similar functionalities in other projects, either reusing the existing code or simply using it for reference will likely shorten development time. Other examples include if a know software fault may occur within a particular context, we can quickly locate all similar defects. To uncover the hidden knowledge, a requisite step is to create an effective code search tool that can scale to the whole open source world, which contains hundreds of billions, even trillions of lines of code. An important aspect of code search is to find copied-and-pasted code or code that looks similar which is code cloning. &lt;br /&gt;
&lt;br /&gt;
Taken the approach that there is much to gain from code clone detection there is a need to compare the effectiveness of clone manipulation when a clone is found.&lt;br /&gt;
&lt;br /&gt;
==Clone Detection Techniques==&lt;br /&gt;
&lt;br /&gt;
===String Based ===&lt;br /&gt;
String based techniques use basic string transformation and comparison algorithms which makes them independent of programming languages. Techniques in this category differ in underlying string comparison algorithm. Comparing calculated signatures per line, is one possibility to identify for matching substrings. Line matching, which comes in two variants, is an alternative which is selected as representative for this category because it uses general string manipulations.&lt;br /&gt;
&lt;br /&gt;
===Simple Line Matching===&lt;br /&gt;
Simple Line Matching is the first variant of line matching in which both detection phases are straightforward. Only minor transformations using string manipulation operations, which can operate using no or very limited knowledge about possible language constructs, are applied. Typical transformations are the removal of empty lines and white spaces. During comparison all lines are compared with each other using a string matching algorithm. This results in a large search space which is usually reduced using hashing buckets. &lt;br /&gt;
&lt;br /&gt;
===Parameterized Line Matching===&lt;br /&gt;
Parameterized Line Matching is another variant of line matching which detects both identical as well as similar code fragments. The idea is that since identifier–names and literals are likely to change when cloning a code fragment, they can be considered as changeable parameters. Therefore, similar fragments which differ only in the naming of these parameters, are allowed.&lt;br /&gt;
&lt;br /&gt;
===Token Based===&lt;br /&gt;
Token based techniques use a more sophisticated transformation algorithm by constructing a token stream from the source code. The presence of such tokens makes it possible to use improved comparison algorithms. Next to parameterized matching with suffix trees, which acts as representative, we include in this category because it also transforms the source code in a token-structure which is afterwards matched. The latter tries to remove much more detail by summarizing non interesting code fragments.&lt;br /&gt;
&lt;br /&gt;
===Parameterized Matching===&lt;br /&gt;
Parameterized Matching With Suffix Trees consists of three consecutive steps manipulating a suffix tree as internal representation. In the first step, a lexical analyser passes over the source text transforming identifiers and literals in parameter symbols, while the typographical structure of each line is encoded in a non-parameter symbol. One symbol always refers to the same identifier, literal or structure. The result of this first step is a parameterized string or p-string.&lt;br /&gt;
Once the p-string is constructed, a criterion to decide whether two sequences in this p-string are a parameterized match or not is necessary. Two strings are a parameterized match if one can be transformed into the other by applying a one-to-one mapping renaming the parameter symbols. An additional encoding prev(S) of the parameter symbols helps us verifying this criterion. In this encoding, each first occurrence of a parameter symbol is replaced by a 0. All later occurrences are replaced by the distance since the previous occurrence of the same symbol. Thus, when two sequences have the same encoding, they are the same except for a systematic renaming of the parameter symbols.&lt;br /&gt;
After the lexical analysis, a data structure called a parameterized suffix tree (p-suffix tree) is built for the pstring. A p-suffix tree is a generalisation of the suffix tree data structure [16] which contains the prev()-encoding of every suffix of a P-string. Concatenating the labels of the arcs on the path from the root to the leaf yields the prev( )-encoding of one suffix. The use of a suffix tree allows a more efficient detection of maximal, parameterized matches.&lt;br /&gt;
&lt;br /&gt;
===Other Techniques===&lt;br /&gt;
AST-based techniques use parsers to first obtain a syntactical representation of the source code, typically an abstract syntax tree (AST). The clone detection algorithms then search for similar subtrees in this AST.&lt;br /&gt;
&lt;br /&gt;
PDG-based approaches  go one step further in obtaining a source code representation of high abstraction. Program dependence graphs (PDGs) contain information of semantically nature, such as control- and data flow of the program.&lt;br /&gt;
&lt;br /&gt;
Metrics-based techniques are related to hashing algorithms. For each fragment of a program the values of a number of metrics is calculated, which are subsequently used to find similar fragments.&lt;br /&gt;
&lt;br /&gt;
==Clone Manipulation==&lt;br /&gt;
So what happens when clone code is? Once the clone detection tools have found code what techniques are available for the tools to solve the issues. The first step is to investigate why the clone code is there. &lt;br /&gt;
&lt;br /&gt;
*Several Questions need to be asked:&lt;br /&gt;
*What classes call the code?&lt;br /&gt;
*What functionality does the code provide?&lt;br /&gt;
*Who “owns” the code?&lt;br /&gt;
*How many systems depend on the code?&lt;br /&gt;
&lt;br /&gt;
Once these questions have been answered and it has been decided that this code cloning needs to be resolved then there are different techniques in solving the code clone issue. There are many tools out there to use for code detection and manipulation. Described below are the different tools researched and some information on the techniques used.[http://sel.ist.osaka-u.ac.jp/cdtools/index-e.html 1]&lt;br /&gt;
&lt;br /&gt;
==Clone Dr==&lt;br /&gt;
The CloneDR™ is built with the DMS/Software Reengineering Toolkit. This technology identifies not only exact, but near-miss duplicates in software systems and can be used on a wide variety of languages. Using compiler technology rather than string matching, it will find clones in spite of changed comments, white spaces, line breaks, case changes, different variable names and even different expressions in the clone body. It detects clones in code and/or data declarations. Detected clones can be filtered by size, and automatically or interactively removed. Clones can be removed by replacing them with equivalent preprocessor macros, type declarations, subroutine calls, or inlined subroutine calls (dependent on language and options), without changing the system functionality. The replacement is automatically generated from the detected clones.&lt;br /&gt;
&lt;br /&gt;
==SHINOBI==&lt;br /&gt;
SHINOBI is supported as an Add-In of Microsoft Visual Studio 2005. It automatically detects clones without the programmer's clear intention at the time of opening and editing source code, and constantly displays the detected clones on the view in IDE. SHINOBI displays the detected clones in order of the ranking f the similarity between the source code on the cursor and the detected clones, and the information in the CVS repository, such as message logs and committed dates of the source code that is detected clones.&lt;br /&gt;
&lt;br /&gt;
==CCFinderX==&lt;br /&gt;
CCFinder can be applied to huge source codes. From a source code with approximately a million lines, CCFinder can detect code clones within several minutes to several hours using a PC/AT compatible. By lexical analysis and transformation based on the syntax of the programming languages, CCFinder can extract code clones correctly from source files, even in cases where the names of variables have been changed. CCFinder can run for C/C++, Java, COBOL, Fortran, etc.&lt;br /&gt;
&lt;br /&gt;
*Multi-threading for multi-core CPU   &lt;br /&gt;
*AST-based preprocessing with an island-parser like parser.&lt;br /&gt;
*Search functions&lt;br /&gt;
*Users can adapt the tool to another programming languages or dialects.&lt;br /&gt;
*Analysis using metrics of code clone&lt;br /&gt;
*For interoperability with another tools, the tool can read/write data in tab separated values text format.&lt;br /&gt;
*Interactive analysis with multiple views of GUI front-end GemX.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
There are many different ways to go about code clone detection. Code clones can be detected on an exact match basis. Unfortunately, using exact match criteria for code clone detection may not be sufficient in all cases. For instance, a programmer may copy a particular piece of code, paste it to another location in the system and proceed to change the pasted code such that it remains syntactically similar to the original code, but not exactly similar. Thus, some form of near-exact clone detection must be employed. Parameterized matching (representative for the token-based approaches) provides a precise picture of a given piece of duplicated code and is robust against rename operations. Therefore it works best in combination with fine-grained refactoring tools that work on the level of statements. This is similar to how the refactoring methods of Extract Method, Move Behaviour, Close to Data, and Transform Conditionals into Polymorphism work.&lt;br /&gt;
Although there are different techniques use than the refactoring code methods the software tools seem to work nicely and continue to get better. The tools take a variety of techniques and make them work at an efficient level. As the technology advances the tools will become more and more useful to detect code clone issues.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
*[Baker1992] B.S. Baker, &amp;quot;A Program for Identifying Duplicated Code&amp;quot;, Proc. Computing Science and Statistics: 24th Symposium on the Interface, 24, pp. 49-57 Mar. 1992.&lt;br /&gt;
&lt;br /&gt;
*[Baker1995] B.S. Baker, &amp;quot;On finding Duplication and Near-Duplication in Large Software System&amp;quot;, Proc. Second IEEE Working Conf. on Reverse Eng., pp. 86-95 Jul. 1995.&lt;br /&gt;
&lt;br /&gt;
*[Balazinska1999] M. Balazinska, E. Merlo, M. Dagenais, B. Lague, and K.A. Kontogiannis, &amp;quot;Measuring Clone Based Reengineering Opportunities&amp;quot;, Proc. 6th IEEE Int'l Symposium on Software Metrics (METRICS '99), pp. 292-303, Boca Raton, Florida, Nov. 1999.&lt;br /&gt;
&lt;br /&gt;
*[Baxter1998] I.D. Baxter, A. Yahin, L. Moura, M. Sant'Anna, and L. Bier, &amp;quot;Clone Detection Using Abstract Syntax Trees&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '98, pp. 368-377, Bethesda, Maryland, Nov. 1998.&lt;br /&gt;
&lt;br /&gt;
*[Burd2002] Elizabeth Burd, John Bailey, &amp;quot;Evaluating Clone Detection Tools for Use during Preventative Maintenance,&amp;quot; Proc. 2nd IEEE International Workshop on Source Code Analysis and Manipulation (SCAM) 2002, pp. 36-43. Montreal, Canada, Oct. 2002.&lt;br /&gt;
&lt;br /&gt;
*[Ducasse1999] S. Ducasse, M. Rieger, and S. Demeyer. &amp;quot;A Language Independent Approach for Detecting Duplicated Code&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '99, pp. 109-118. Oxford, England. Aug. 1999.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
*1 - [http://sel.ist.osaka-u.ac.jp/cdtools/index-e.html Code Clone Related Tools]&lt;br /&gt;
*2 - [http://research.cs.queensu.ca/home/cordy/Papers/RCK_SCP_Clones.pdf SCP Clones]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29825</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 2 SN</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29825"/>
		<updated>2009-11-22T16:55:07Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Clone Detection and Clone Manipulation'''&lt;br /&gt;
&lt;br /&gt;
=='''Thesis'''==&lt;br /&gt;
The DRY principle says that a particular code fragment should not be repeated more than once in a program. But it happens. And when it does, it is good to be able to find the multiple code &amp;quot;clones.&amp;quot; A variety of tools have been designed for this, and some of them even allow joint editing of the clones. Survey the techniques for dealing with the problem, and compare the effectiveness with refactoring (e.g., Extract Method).&lt;br /&gt;
&lt;br /&gt;
=='''Code Cloning'''==&lt;br /&gt;
Often in computer systems whether small or large, code can become complex. As systems become larger and larger and more and more people work on the system there are often cases when the code becomes duplicated. Sometimes based on system architecture this is unavoidable. However often times replicated code can be avoided and should be as much as possible. It is always best approach to replace, reuse, and refactor code as much as possible.  &lt;br /&gt;
&lt;br /&gt;
There are times when code cloning is unavoidable. Factors such as design, security restrictions, rights of code, and class interaction can all be factors on why code cannot be manipulated in a way in which code cloning is not cannot be fixed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Clone Detection'''==&lt;br /&gt;
&lt;br /&gt;
Clone detection finds code in large software systems that has been replicated and modified by hand.&lt;br /&gt;
Remarkably, clone detection works because people copy conceptually identifiable blocks of code, and make only a few changes. This means the same syntax is detectably repeated. Each identified clone thus indicates the presence of a useful problem domain concept, and simultaneously provides an example implementation. Differences between the copies identify parameters or points of variation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Clones can enhance a product line development in a number of ways:&lt;br /&gt;
 &lt;br /&gt;
*Removal of redundant code&lt;br /&gt;
*Lowering maintenance costs&lt;br /&gt;
*Identification of domain concepts for use in the present system or the next&lt;br /&gt;
*Identification of parametrized reusable implementations&lt;br /&gt;
*Sometimes reveal code bugs directly by inspection of parameter bindings with inconsistent actual or conceptual types&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is much hidden knowledge in open source software that can be valuable for improving software quality and productivity. For example, if we want to implement a new feature and know there exists code with similar functionalities in other projects, either reusing the existing code or simply using it for reference will likely shorten development time. Other examples include if a know software fault may occur within a particular context, we can quickly locate all similar defects. To uncover the hidden knowledge, a requisite step is to create an effective code search tool that can scale to the whole open source world, which contains hundreds of billions, even trillions of lines of code. An important aspect of code search is to find copied-and-pasted code or code that looks similar which is code cloning. &lt;br /&gt;
&lt;br /&gt;
Taken the approach that there is much to gain from code clone detection there is a need to compare the effectiveness of clone manipulation when a clone is found.&lt;br /&gt;
&lt;br /&gt;
==Clone Detection Techniques==&lt;br /&gt;
&lt;br /&gt;
===String Based ===&lt;br /&gt;
String based techniques use basic string transformation and comparison algorithms which makes them independent of programming languages. Techniques in this category differ in underlying string comparison algorithm. Comparing calculated signatures per line, is one possibility to identify for matching substrings. Line matching, which comes in two variants, is an alternative which is selected as representative for this category because it uses general string manipulations.&lt;br /&gt;
&lt;br /&gt;
===Simple Line Matching===&lt;br /&gt;
Simple Line Matching is the first variant of line matching in which both detection phases are straightforward. Only minor transformations using string manipulation operations, which can operate using no or very limited knowledge about possible language constructs, are applied. Typical transformations are the removal of empty lines and white spaces. During comparison all lines are compared with each other using a string matching algorithm. This results in a large search space which is usually reduced using hashing buckets. &lt;br /&gt;
&lt;br /&gt;
===Parameterized Line Matching===&lt;br /&gt;
Parameterized Line Matching is another variant of line matching which detects both identical as well as similar code fragments. The idea is that since identifier–names and literals are likely to change when cloning a code fragment, they can be considered as changeable parameters. Therefore, similar fragments which differ only in the naming of these parameters, are allowed.&lt;br /&gt;
&lt;br /&gt;
===Token Based===&lt;br /&gt;
Token based techniques use a more sophisticated transformation algorithm by constructing a token stream from the source code. The presence of such tokens makes it possible to use improved comparison algorithms. Next to parameterized matching with suffix trees, which acts as representative, we include in this category because it also transforms the source code in a token-structure which is afterwards matched. The latter tries to remove much more detail by summarizing non interesting code fragments.&lt;br /&gt;
&lt;br /&gt;
===Parameterized Matching===&lt;br /&gt;
Parameterized Matching With Suffix Trees consists of three consecutive steps manipulating a suffix tree as internal representation. In the first step, a lexical analyser passes over the source text transforming identifiers and literals in parameter symbols, while the typographical structure of each line is encoded in a non-parameter symbol. One symbol always refers to the same identifier, literal or structure. The result of this first step is a parameterized string or p-string.&lt;br /&gt;
Once the p-string is constructed, a criterion to decide whether two sequences in this p-string are a parameterized match or not is necessary. Two strings are a parameterized match if one can be transformed into the other by applying a one-to-one mapping renaming the parameter symbols. An additional encoding prev(S) of the parameter symbols helps us verifying this criterion. In this encoding, each first occurrence of a parameter symbol is replaced by a 0. All later occurrences are replaced by the distance since the previous occurrence of the same symbol. Thus, when two sequences have the same encoding, they are the same except for a systematic renaming of the parameter symbols.&lt;br /&gt;
After the lexical analysis, a data structure called a parameterized suffix tree (p-suffix tree) is built for the pstring. A p-suffix tree is a generalisation of the suffix tree data structure [16] which contains the prev()-encoding of every suffix of a P-string. Concatenating the labels of the arcs on the path from the root to the leaf yields the prev( )-encoding of one suffix. The use of a suffix tree allows a more efficient detection of maximal, parameterized matches.&lt;br /&gt;
&lt;br /&gt;
===Other Techniques===&lt;br /&gt;
AST-based techniques use parsers to first obtain a syntactical representation of the source code, typically an abstract syntax tree (AST). The clone detection algorithms then search for similar subtrees in this AST.&lt;br /&gt;
&lt;br /&gt;
PDG-based approaches  go one step further in obtaining a source code representation of high abstraction. Program dependence graphs (PDGs) contain information of semantically nature, such as control- and data flow of the program.&lt;br /&gt;
&lt;br /&gt;
Metrics-based techniques are related to hashing algorithms. For each fragment of a program the values of a number of metrics is calculated, which are subsequently used to find similar fragments.&lt;br /&gt;
&lt;br /&gt;
==Clone Manipulation==&lt;br /&gt;
So what happens when clone code is? Once the clone detection tools have found code what techniques are available for the tools to solve the issues. The first step is to investigate why the clone code is there. &lt;br /&gt;
&lt;br /&gt;
*Several Questions need to be asked:&lt;br /&gt;
*What classes call the code?&lt;br /&gt;
*What functionality does the code provide?&lt;br /&gt;
*Who “owns” the code?&lt;br /&gt;
*How many systems depend on the code?&lt;br /&gt;
&lt;br /&gt;
Once these questions have been answered and it has been decided that this code cloning needs to be resolved then there are different techniques in solving the code clone issue. There are many tools out there to use for code detection and manipulation. Described below are the different tools researched and some information on the techniques used.&lt;br /&gt;
&lt;br /&gt;
==Clone Dr==&lt;br /&gt;
The CloneDR™ is built with the DMS/Software Reengineering Toolkit. This technology identifies not only exact, but near-miss duplicates in software systems and can be used on a wide variety of languages. Using compiler technology rather than string matching, it will find clones in spite of changed comments, white spaces, line breaks, case changes, different variable names and even different expressions in the clone body. It detects clones in code and/or data declarations. Detected clones can be filtered by size, and automatically or interactively removed. Clones can be removed by replacing them with equivalent preprocessor macros, type declarations, subroutine calls, or inlined subroutine calls (dependent on language and options), without changing the system functionality. The replacement is automatically generated from the detected clones.&lt;br /&gt;
&lt;br /&gt;
==SHINOBI==&lt;br /&gt;
SHINOBI is supported as an Add-In of Microsoft Visual Studio 2005. It automatically detects clones without the programmer's clear intention at the time of opening and editing source code, and constantly displays the detected clones on the view in IDE. SHINOBI displays the detected clones in order of the ranking f the similarity between the source code on the cursor and the detected clones, and the information in the CVS repository, such as message logs and committed dates of the source code that is detected clones.&lt;br /&gt;
&lt;br /&gt;
==CCFinderX==&lt;br /&gt;
CCFinder can be applied to huge source codes. From a source code with approximately a million lines, CCFinder can detect code clones within several minutes to several hours using a PC/AT compatible. By lexical analysis and transformation based on the syntax of the programming languages, CCFinder can extract code clones correctly from source files, even in cases where the names of variables have been changed. CCFinder can run for C/C++, Java, COBOL, Fortran, etc.&lt;br /&gt;
&lt;br /&gt;
*Multi-threading for multi-core CPU   &lt;br /&gt;
*AST-based preprocessing with an island-parser like parser.&lt;br /&gt;
*Search functions&lt;br /&gt;
*Users can adapt the tool to another programming languages or dialects.&lt;br /&gt;
*Analysis using metrics of code clone&lt;br /&gt;
*For interoperability with another tools, the tool can read/write data in tab separated values text format.&lt;br /&gt;
*Interactive analysis with multiple views of GUI front-end GemX.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
There are many different ways to go about code clone detection. Code clones can be detected on an exact match basis. Unfortunately, using exact match criteria for code clone detection may not be sufficient in all cases. For instance, a programmer may copy a particular piece of code, paste it to another location in the system and proceed to change the pasted code such that it remains syntactically similar to the original code, but not exactly similar. Thus, some form of near-exact clone detection must be employed. Parameterized matching (representative for the token-based approaches) provides a precise picture of a given piece of duplicated code and is robust against rename operations. Therefore it works best in combination with fine-grained refactoring tools that work on the level of statements. This is similar to how the refactoring methods of Extract Method, Move Behaviour, Close to Data, and Transform Conditionals into Polymorphism work.&lt;br /&gt;
Although there are different techniques use than the refactoring code methods the software tools seem to work nicely and continue to get better. The tools take a variety of techniques and make them work at an efficient level. As the technology advances the tools will become more and more useful to detect code clone issues.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
*[Baker1992] B.S. Baker, &amp;quot;A Program for Identifying Duplicated Code&amp;quot;, Proc. Computing Science and Statistics: 24th Symposium on the Interface, 24, pp. 49-57 Mar. 1992.&lt;br /&gt;
&lt;br /&gt;
*[Baker1995] B.S. Baker, &amp;quot;On finding Duplication and Near-Duplication in Large Software System&amp;quot;, Proc. Second IEEE Working Conf. on Reverse Eng., pp. 86-95 Jul. 1995.&lt;br /&gt;
&lt;br /&gt;
*[Balazinska1999] M. Balazinska, E. Merlo, M. Dagenais, B. Lague, and K.A. Kontogiannis, &amp;quot;Measuring Clone Based Reengineering Opportunities&amp;quot;, Proc. 6th IEEE Int'l Symposium on Software Metrics (METRICS '99), pp. 292-303, Boca Raton, Florida, Nov. 1999.&lt;br /&gt;
&lt;br /&gt;
*[Baxter1998] I.D. Baxter, A. Yahin, L. Moura, M. Sant'Anna, and L. Bier, &amp;quot;Clone Detection Using Abstract Syntax Trees&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '98, pp. 368-377, Bethesda, Maryland, Nov. 1998.&lt;br /&gt;
&lt;br /&gt;
*[Burd2002] Elizabeth Burd, John Bailey, &amp;quot;Evaluating Clone Detection Tools for Use during Preventative Maintenance,&amp;quot; Proc. 2nd IEEE International Workshop on Source Code Analysis and Manipulation (SCAM) 2002, pp. 36-43. Montreal, Canada, Oct. 2002.&lt;br /&gt;
&lt;br /&gt;
*[Ducasse1999] S. Ducasse, M. Rieger, and S. Demeyer. &amp;quot;A Language Independent Approach for Detecting Duplicated Code&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '99, pp. 109-118. Oxford, England. Aug. 1999.&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29824</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 2 SN</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29824"/>
		<updated>2009-11-22T16:54:23Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Clone Detection and Clone Manipulation'''&lt;br /&gt;
&lt;br /&gt;
=='''Thesis'''==&lt;br /&gt;
The DRY principle says that a particular code fragment should not be repeated more than once in a program. But it happens. And when it does, it is good to be able to find the multiple code &amp;quot;clones.&amp;quot; A variety of tools have been designed for this, and some of them even allow joint editing of the clones. Survey the techniques for dealing with the problem, and compare the effectiveness with refactoring (e.g., Extract Method).&lt;br /&gt;
&lt;br /&gt;
=='''Code Cloning'''==&lt;br /&gt;
Often in computer systems whether small or large, code can become complex. As systems become larger and larger and more and more people work on the system there are often cases when the code becomes duplicated. Sometimes based on system architecture this is unavoidable. However often times replicated code can be avoided and should be as much as possible. It is always best approach to replace, reuse, and refactor code as much as possible.  &lt;br /&gt;
&lt;br /&gt;
There are times when code cloning is unavoidable. Factors such as design, security restrictions, rights of code, and class interaction can all be factors on why code cannot be manipulated in a way in which code cloning is not cannot be fixed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Clone Detection'''==&lt;br /&gt;
&lt;br /&gt;
Clone detection finds code in large software systems that has been replicated and modified by hand.&lt;br /&gt;
Remarkably, clone detection works because people copy conceptually identifiable blocks of code, and make only a few changes. This means the same syntax is detectably repeated. Each identified clone thus indicates the presence of a useful problem domain concept, and simultaneously provides an example implementation. Differences between the copies identify parameters or points of variation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Clones can enhance a product line development in a number of ways:&lt;br /&gt;
 &lt;br /&gt;
*Removal of redundant code&lt;br /&gt;
*Lowering maintenance costs&lt;br /&gt;
*Identification of domain concepts for use in the present system or the next&lt;br /&gt;
*Identification of parametrized reusable implementations&lt;br /&gt;
*Sometimes reveal code bugs directly by inspection of parameter bindings with inconsistent actual or conceptual types&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is much hidden knowledge in open source software that can be valuable for improving software quality and productivity. For example, if we want to implement a new feature and know there exists code with similar functionalities in other projects, either reusing the existing code or simply using it for reference will likely shorten development time. Other examples include if a know software fault may occur within a particular context, we can quickly locate all similar defects. To uncover the hidden knowledge, a requisite step is to create an effective code search tool that can scale to the whole open source world, which contains hundreds of billions, even trillions of lines of code. An important aspect of code search is to find copied-and-pasted code or code that looks similar which is code cloning. &lt;br /&gt;
&lt;br /&gt;
Taken the approach that there is much to gain from code clone detection there is a need to compare the effectiveness of clone manipulation when a clone is found.&lt;br /&gt;
&lt;br /&gt;
==Clone Detection Techniques==&lt;br /&gt;
&lt;br /&gt;
===String Based ===&lt;br /&gt;
String based techniques use basic string transformation and comparison algorithms which makes them independent of programming languages. Techniques in this category differ in underlying string comparison algorithm. Comparing calculated signatures per line, is one possibility to identify for matching substrings. Line matching, which comes in two variants, is an alternative which is selected as representative for this category because it uses general string manipulations.&lt;br /&gt;
&lt;br /&gt;
===Simple Line Matching===&lt;br /&gt;
Simple Line Matching is the first variant of line matching in which both detection phases are straightforward. Only minor transformations using string manipulation operations, which can operate using no or very limited knowledge about possible language constructs, are applied. Typical transformations are the removal of empty lines and white spaces. During comparison all lines are compared with each other using a string matching algorithm. This results in a large search space which is usually reduced using hashing buckets. &lt;br /&gt;
&lt;br /&gt;
===Parameterized Line Matching===&lt;br /&gt;
Parameterized Line Matching is another variant of line matching which detects both identical as well as similar code fragments. The idea is that since identifier–names and literals are likely to change when cloning a code fragment, they can be considered as changeable parameters. Therefore, similar fragments which differ only in the naming of these parameters, are allowed.&lt;br /&gt;
&lt;br /&gt;
===Token Based===&lt;br /&gt;
Token based techniques use a more sophisticated transformation algorithm by constructing a token stream from the source code. The presence of such tokens makes it possible to use improved comparison algorithms. Next to parameterized matching with suffix trees, which acts as representative, we include in this category because it also transforms the source code in a token-structure which is afterwards matched. The latter tries to remove much more detail by summarizing non interesting code fragments.&lt;br /&gt;
&lt;br /&gt;
===Parameterized Matching===&lt;br /&gt;
Parameterized Matching With Suffix Trees consists of three consecutive steps manipulating a suffix tree as internal representation. In the first step, a lexical analyser passes over the source text transforming identifiers and literals in parameter symbols, while the typographical structure of each line is encoded in a non-parameter symbol. One symbol always refers to the same identifier, literal or structure. The result of this first step is a parameterized string or p-string.&lt;br /&gt;
Once the p-string is constructed, a criterion to decide whether two sequences in this p-string are a parameterized match or not is necessary. Two strings are a parameterized match if one can be transformed into the other by applying a one-to-one mapping renaming the parameter symbols. An additional encoding prev(S) of the parameter symbols helps us verifying this criterion. In this encoding, each first occurrence of a parameter symbol is replaced by a 0. All later occurrences are replaced by the distance since the previous occurrence of the same symbol. Thus, when two sequences have the same encoding, they are the same except for a systematic renaming of the parameter symbols.&lt;br /&gt;
After the lexical analysis, a data structure called a parameterized suffix tree (p-suffix tree) is built for the pstring. A p-suffix tree is a generalisation of the suffix tree data structure [16] which contains the prev()-encoding of every suffix of a P-string. Concatenating the labels of the arcs on the path from the root to the leaf yields the prev( )-encoding of one suffix. The use of a suffix tree allows a more efficient detection of maximal, parameterized matches.&lt;br /&gt;
&lt;br /&gt;
===Other Techniques===&lt;br /&gt;
AST-based techniques use parsers to first obtain a syntactical representation of the source code, typically an abstract syntax tree (AST). The clone detection algorithms then search for similar subtrees in this AST.&lt;br /&gt;
&lt;br /&gt;
PDG-based approaches  go one step further in obtaining a source code representation of high abstraction. Program dependence graphs (PDGs) contain information of semantically nature, such as control- and data flow of the program.&lt;br /&gt;
&lt;br /&gt;
Metrics-based techniques are related to hashing algorithms. For each fragment of a program the values of a number of metrics is calculated, which are subsequently used to find similar fragments.&lt;br /&gt;
&lt;br /&gt;
==Clone Manipulation==&lt;br /&gt;
So what happens when clone code is? Once the clone detection tools have found code what techniques are available for the tools to solve the issues. The first step is to investigate why the clone code is there. &lt;br /&gt;
&lt;br /&gt;
*Several Questions need to be asked:&lt;br /&gt;
*What classes call the code?&lt;br /&gt;
*What functionality does the code provide?&lt;br /&gt;
*Who “owns” the code?&lt;br /&gt;
*How many systems depend on the code?&lt;br /&gt;
&lt;br /&gt;
Once these questions have been answered and it has been decided that this code cloning needs to be resolved then there are different techniques in solving the code clone issue. There are many tools out there to use for code detection and manipulation. Described below are the different tools researched and some information on the techniques used.&lt;br /&gt;
&lt;br /&gt;
==Clone Dr==&lt;br /&gt;
The CloneDR™ is built with the DMS/Software Reengineering Toolkit. This technology identifies not only exact, but near-miss duplicates in software systems and can be used on a wide variety of languages. Using compiler technology rather than string matching, it will find clones in spite of changed comments, white spaces, line breaks, case changes, different variable names and even different expressions in the clone body. It detects clones in code and/or data declarations. Detected clones can be filtered by size, and automatically or interactively removed. Clones can be removed by replacing them with equivalent preprocessor macros, type declarations, subroutine calls, or inlined subroutine calls (dependent on language and options), without changing the system functionality. The replacement is automatically generated from the detected clones.&lt;br /&gt;
&lt;br /&gt;
==SHINOBI==&lt;br /&gt;
SHINOBI is supported as an Add-In of Microsoft Visual Studio 2005. It automatically detects clones without the programmer's clear intention at the time of opening and editing source code, and constantly displays the detected clones on the view in IDE. SHINOBI displays the detected clones in order of the ranking f the similarity between the source code on the cursor and the detected clones, and the information in the CVS repository, such as message logs and committed dates of the source code that is detected clones.&lt;br /&gt;
&lt;br /&gt;
==CCFinderX==&lt;br /&gt;
CCFinder can be applied to huge source codes. From a source code with approximately a million lines, CCFinder can detect code clones within several minutes to several hours using a PC/AT compatible. By lexical analysis and transformation based on the syntax of the programming languages, CCFinder can extract code clones correctly from source files, even in cases where the names of variables have been changed. CCFinder can run for C/C++, Java, COBOL, Fortran, etc.&lt;br /&gt;
&lt;br /&gt;
*Multi-threading for multi-core CPU   &lt;br /&gt;
*AST-based preprocessing with an island-parser like parser.&lt;br /&gt;
*Search functions&lt;br /&gt;
*Users can adapt the tool to another programming languages or dialects.&lt;br /&gt;
*Analysis using metrics of code clone&lt;br /&gt;
*For interoperability with another tools, the tool can read/write data in tab separated values text format.&lt;br /&gt;
*Interactive analysis with multiple views of GUI front-end GemX.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
There are many different ways to go about code clone detection. Code clones can be detected on an exact match basis. Unfortunately, using exact match criteria for code clone detection may not be sufficient in all cases. For instance, a programmer may copy a particular piece of code, paste it to another location in the system and proceed to change the pasted code such that it remains syntactically similar to the original code, but not exactly similar. Thus, some form of near-exact clone detection must be employed. Parameterized matching (representative for the token-based approaches) provides a precise picture of a given piece of duplicated code and is robust against rename operations. Therefore it works best in combination with fine-grained refactoring tools that work on the level of statements. This is similar to how the refactoring methods of Extract Method, Move Behaviour, Close to Data, and Transform Conditionals into Polymorphism work.&lt;br /&gt;
Although there are different techniques use than the refactoring code methods the software tools seem to work nicely and continue to get better. The tools take a variety of techniques and make them work at an efficient level. As the technology advances the tools will become more and more useful to detect code clone issues.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[Baker1992] B.S. Baker, &amp;quot;A Program for Identifying Duplicated Code&amp;quot;, Proc. Computing Science and Statistics: 24th Symposium on the Interface, 24, pp. 49-57 Mar. 1992.&lt;br /&gt;
[Baker1995] B.S. Baker, &amp;quot;On finding Duplication and Near-Duplication in Large Software System&amp;quot;, Proc. Second IEEE Working Conf. on Reverse Eng., pp. 86-95 Jul. 1995.&lt;br /&gt;
[Balazinska1999] M. Balazinska, E. Merlo, M. Dagenais, B. Lague, and K.A. Kontogiannis, &amp;quot;Measuring Clone Based Reengineering Opportunities&amp;quot;, Proc. 6th IEEE Int'l Symposium on Software Metrics (METRICS '99), pp. 292-303, Boca Raton, Florida, Nov. 1999.&lt;br /&gt;
[Baxter1998] I.D. Baxter, A. Yahin, L. Moura, M. Sant'Anna, and L. Bier, &amp;quot;Clone Detection Using Abstract Syntax Trees&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '98, pp. 368-377, Bethesda, Maryland, Nov. 1998.&lt;br /&gt;
[Burd2002] Elizabeth Burd, John Bailey, &amp;quot;Evaluating Clone Detection Tools for Use during Preventative Maintenance,&amp;quot; Proc. 2nd IEEE International Workshop on Source Code Analysis and Manipulation (SCAM) 2002, pp. 36-43. Montreal, Canada, Oct. 2002.&lt;br /&gt;
[Ducasse1999] S. Ducasse, M. Rieger, and S. Demeyer. &amp;quot;A Language Independent Approach for Detecting Duplicated Code&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '99, pp. 109-118. Oxford, England. Aug. 1999.&lt;br /&gt;
[Fowler1999] Martin Fowler. Refactoring: improving the design of existing code. Addison Wesley. 1999.&lt;br /&gt;
[Kontogiannis1996] K. Kontogiannis, R. DeMori, E. Merlo, M. Galler, and M.Bernstein, &amp;quot;Pattern Matching Techniques for Clone Detection,&amp;quot; Journal of Automated Software Engineering, Kluwer Academic Publishers, Vol. 3. pp.77-108, 1996.&lt;br /&gt;
[Imai2002] T. Imai, Y. Kataoka, and T. Fukaya, &amp;quot;Evaluating software maintenance cost using functional redundancy metrics,&amp;quot; In Proc. 26th International Computer Software and Applications Conference (compsac 2002), pp.299-306, 2002.&lt;br /&gt;
[Johnson1994] J. H. Johnson, &amp;quot;Substring Matching for Clone Detection and Change Tracking&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '94, pp. 120-126. Victoria, British Columbia, Canada. Sep. 1994.&lt;br /&gt;
[Mayrand1996] J. Mayland, C. Leblanc, and E. M. Merlo. &amp;quot;Experiment on the Automatic Detection of Function Clones in a Software System Using Metrics&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '96, pp. 244-253, Monterey, California, Nov. 1996.&lt;br /&gt;
[Laguë1997] B. Laguë, E.M. Merlo, J. Mayrand, and J. Hudepohl. &amp;quot;Assessing the Benefits of Incorporating Function Clone Detection in a Development Process&amp;quot;, Proc. IEEE Int'l Conf. on Software Maintenance (ICSM) '97, pp. 314-321, Bari, Italy. Oct. 1997.&lt;br /&gt;
[Prechelt2000] Prechelt, L.; Malpohl, G.; Philippsen, M. &amp;quot;JPlag: Finding plagiarisms among a set of programs,&amp;quot; Technical Report, University of Karlsruhe, Department of Informatics, 2000.&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_22_SN&amp;diff=29823</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 22 SN</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_22_SN&amp;diff=29823"/>
		<updated>2009-11-22T16:45:16Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Clone Detection and Clone Manipulation'''&lt;br /&gt;
&lt;br /&gt;
=='''Thesis'''==&lt;br /&gt;
The DRY principle says that a particular code fragment should not be repeated more than once in a program. But it happens. And when it does, it is good to be able to find the multiple code &amp;quot;clones.&amp;quot; A variety of tools have been designed for this, and some of them even allow joint editing of the clones. Survey the techniques for dealing with the problem, and compare the effectiveness with refactoring (e.g., Extract Method).&lt;br /&gt;
&lt;br /&gt;
=='''Code Cloning'''==&lt;br /&gt;
Often in computer systems whether small or large, code can become complex. As systems become larger and larger and more and more people work on the system there are often cases when the code becomes duplicated. Sometimes based on system architecture this is unavoidable. However often times replicated code can be avoided and should be as much as possible. It is always best approach to replace, reuse, and refactor code as much as possible.  &lt;br /&gt;
&lt;br /&gt;
There are times when code cloning is unavoidable. Factors such as design, security restrictions, rights of code, and class interaction can all be factors on why code cannot be manipulated in a way in which code cloning is not cannot be fixed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Clone Detection'''==&lt;br /&gt;
&lt;br /&gt;
Clone detection finds code in large software systems that has been replicated and modified by hand.&lt;br /&gt;
Remarkably, clone detection works because people copy conceptually identifiable blocks of code, and make only a few changes. This means the same syntax is detectably repeated. Each identified clone thus indicates the presence of a useful problem domain concept, and simultaneously provides an example implementation. Differences between the copies identify parameters or points of variation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Clones can enhance a product line development in a number of ways:&lt;br /&gt;
 &lt;br /&gt;
*Removal of redundant code&lt;br /&gt;
*Lowering maintenance costs&lt;br /&gt;
*Identification of domain concepts for use in the present system or the next&lt;br /&gt;
*Identification of parametrized reusable implementations&lt;br /&gt;
*Sometimes reveal code bugs directly by inspection of parameter bindings with inconsistent actual or conceptual types&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is much hidden knowledge in open source software that can be valuable for improving software quality and productivity. For example, if we want to implement a new feature and know there exists code with similar functionalities in other projects, either reusing the existing code or simply using it for reference will likely shorten development time. Other examples include if a know software fault may occur within a particular context, we can quickly locate all similar defects. To uncover the hidden knowledge, a requisite step is to create an effective code search tool that can scale to the whole open source world, which contains hundreds of billions, even trillions of lines of code. An important aspect of code search is to find copied-and-pasted code or code that looks similar which is code cloning. &lt;br /&gt;
&lt;br /&gt;
Taken the approach that there is much to gain from code clone detection there is a need to compare the effectiveness of clone manipulation when a clone is found.&lt;br /&gt;
&lt;br /&gt;
==Clone Detection Techniques==&lt;br /&gt;
&lt;br /&gt;
===String Based ===&lt;br /&gt;
String based techniques use basic string transformation and comparison algorithms which makes them independent of programming languages. Techniques in this category differ in underlying string comparison algorithm. Comparing calculated signatures per line, is one possibility to identify for matching substrings. Line matching, which comes in two variants, is an alternative which is selected as representative for this category because it uses general string manipulations.&lt;br /&gt;
&lt;br /&gt;
===Simple Line Matching===&lt;br /&gt;
Simple Line Matching is the first variant of line matching in which both detection phases are straightforward. Only minor transformations using string manipulation operations, which can operate using no or very limited knowledge about possible language constructs, are applied. Typical transformations are the removal of empty lines and white spaces. During comparison all lines are compared with each other using a string matching algorithm. This results in a large search space which is usually reduced using hashing buckets. &lt;br /&gt;
&lt;br /&gt;
===Parameterized Line Matching===&lt;br /&gt;
Parameterized Line Matching is another variant of line matching which detects both identical as well as similar code fragments. The idea is that since identifier–names and literals are likely to change when cloning a code fragment, they can be considered as changeable parameters. Therefore, similar fragments which differ only in the naming of these parameters, are allowed.&lt;br /&gt;
&lt;br /&gt;
===Token Based===&lt;br /&gt;
Token based techniques use a more sophisticated transformation algorithm by constructing a token stream from the source code. The presence of such tokens makes it possible to use improved comparison algorithms. Next to parameterized matching with suffix trees, which acts as representative, we include in this category because it also transforms the source code in a token-structure which is afterwards matched. The latter tries to remove much more detail by summarizing non interesting code fragments.&lt;br /&gt;
&lt;br /&gt;
===Parameterized Matching===&lt;br /&gt;
Parameterized Matching With Suffix Trees consists of three consecutive steps manipulating a suffix tree as internal representation. In the first step, a lexical analyser passes over the source text transforming identifiers and literals in parameter symbols, while the typographical structure of each line is encoded in a non-parameter symbol. One symbol always refers to the same identifier, literal or structure. The result of this first step is a parameterized string or p-string.&lt;br /&gt;
Once the p-string is constructed, a criterion to decide whether two sequences in this p-string are a parameterized match or not is necessary. Two strings are a parameterized match if one can be transformed into the other by applying a one-to-one mapping renaming the parameter symbols. An additional encoding prev(S) of the parameter symbols helps us verifying this criterion. In this encoding, each first occurrence of a parameter symbol is replaced by a 0. All later occurrences are replaced by the distance since the previous occurrence of the same symbol. Thus, when two sequences have the same encoding, they are the same except for a systematic renaming of the parameter symbols.&lt;br /&gt;
After the lexical analysis, a data structure called a parameterized suffix tree (p-suffix tree) is built for the pstring. A p-suffix tree is a generalisation of the suffix tree data structure [16] which contains the prev()-encoding of every suffix of a P-string. Concatenating the labels of the arcs on the path from the root to the leaf yields the prev( )-encoding of one suffix. The use of a suffix tree allows a more efficient detection of maximal, parameterized matches.&lt;br /&gt;
&lt;br /&gt;
===Other Techniques===&lt;br /&gt;
AST-based techniques use parsers to first obtain a syntactical representation of the source code, typically an abstract syntax tree (AST). The clone detection algorithms then search for similar subtrees in this AST.&lt;br /&gt;
&lt;br /&gt;
PDG-based approaches  go one step further in obtaining a source code representation of high abstraction. Program dependence graphs (PDGs) contain information of semantically nature, such as control- and data flow of the program.&lt;br /&gt;
&lt;br /&gt;
Metrics-based techniques are related to hashing algorithms. For each fragment of a program the values of a number of metrics is calculated, which are subsequently used to find similar fragments.&lt;br /&gt;
&lt;br /&gt;
==Clone Manipulation==&lt;br /&gt;
So what happens when clone code is? Once the clone detection tools have found code what techniques are available for the tools to solve the issues. The first step is to investigate why the clone code is there. &lt;br /&gt;
&lt;br /&gt;
*Several Questions need to be asked:&lt;br /&gt;
*What classes call the code?&lt;br /&gt;
*What functionality does the code provide?&lt;br /&gt;
*Who “owns” the code?&lt;br /&gt;
*How many systems depend on the code?&lt;br /&gt;
&lt;br /&gt;
Once these questions have been answered and it has been decided that this code cloning needs to be resolved then there are different techniques in solving the code clone issue. There are many tools out there to use for code detection and manipulation. Described below are the different tools researched and some information on the techniques used.&lt;br /&gt;
&lt;br /&gt;
==Clone Dr==&lt;br /&gt;
The CloneDR™ is built with the DMS/Software Reengineering Toolkit. This technology identifies not only exact, but near-miss duplicates in software systems and can be used on a wide variety of languages. Using compiler technology rather than string matching, it will find clones in spite of changed comments, white spaces, line breaks, case changes, different variable names and even different expressions in the clone body. It detects clones in code and/or data declarations. Detected clones can be filtered by size, and automatically or interactively removed. Clones can be removed by replacing them with equivalent preprocessor macros, type declarations, subroutine calls, or inlined subroutine calls (dependent on language and options), without changing the system functionality. The replacement is automatically generated from the detected clones.&lt;br /&gt;
&lt;br /&gt;
==SHINOBI==&lt;br /&gt;
SHINOBI is supported as an Add-In of Microsoft Visual Studio 2005. It automatically detects clones without the programmer's clear intention at the time of opening and editing source code, and constantly displays the detected clones on the view in IDE. SHINOBI displays the detected clones in order of the ranking f the similarity between the source code on the cursor and the detected clones, and the information in the CVS repository, such as message logs and committed dates of the source code that is detected clones.&lt;br /&gt;
&lt;br /&gt;
==CCFinderX==&lt;br /&gt;
CCFinder can be applied to huge source codes. From a source code with approximately a million lines, CCFinder can detect code clones within several minutes to several hours using a PC/AT compatible. By lexical analysis and transformation based on the syntax of the programming languages, CCFinder can extract code clones correctly from source files, even in cases where the names of variables have been changed. CCFinder can run for C/C++, Java, COBOL, Fortran, etc.&lt;br /&gt;
&lt;br /&gt;
*Multi-threading for multi-core CPU   &lt;br /&gt;
*AST-based preprocessing with an island-parser like parser.&lt;br /&gt;
*Search functions&lt;br /&gt;
*Users can adapt the tool to another programming languages or dialects.&lt;br /&gt;
*Analysis using metrics of code clone&lt;br /&gt;
*For interoperability with another tools, the tool can read/write data in tab separated values text format.&lt;br /&gt;
*Interactive analysis with multiple views of GUI front-end GemX.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
There are many different ways to go about code clone detection. Code clones can be detected on an exact match basis. Unfortunately, using exact match criteria for code clone detection may not be sufficient in all cases. For instance, a programmer may copy a particular piece of code, paste it to another location in the system and proceed to change the pasted code such that it remains syntactically similar to the original code, but not exactly similar. Thus, some form of near-exact clone detection must be employed. Parameterized matching (representative for the token-based approaches) provides a precise picture of a given piece of duplicated code and is robust against rename operations. Therefore it works best in combination with fine-grained refactoring tools that work on the level of statements. This is similar to how the refactoring methods of Extract Method, Move Behaviour, Close to Data, and Transform Conditionals into Polymorphism work.&lt;br /&gt;
Although there are different techniques use than the refactoring code methods the software tools seem to work nicely and continue to get better. The tools take a variety of techniques and make them work at an efficient level. As the technology advances the tools will become more and more useful to detect code clone issues.&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29822</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 2 SN</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29822"/>
		<updated>2009-11-22T16:44:15Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Clone Detection and Clone Manipulation'''&lt;br /&gt;
&lt;br /&gt;
=='''Thesis'''==&lt;br /&gt;
The DRY principle says that a particular code fragment should not be repeated more than once in a program. But it happens. And when it does, it is good to be able to find the multiple code &amp;quot;clones.&amp;quot; A variety of tools have been designed for this, and some of them even allow joint editing of the clones. Survey the techniques for dealing with the problem, and compare the effectiveness with refactoring (e.g., Extract Method).&lt;br /&gt;
&lt;br /&gt;
=='''Code Cloning'''==&lt;br /&gt;
Often in computer systems whether small or large, code can become complex. As systems become larger and larger and more and more people work on the system there are often cases when the code becomes duplicated. Sometimes based on system architecture this is unavoidable. However often times replicated code can be avoided and should be as much as possible. It is always best approach to replace, reuse, and refactor code as much as possible.  &lt;br /&gt;
&lt;br /&gt;
There are times when code cloning is unavoidable. Factors such as design, security restrictions, rights of code, and class interaction can all be factors on why code cannot be manipulated in a way in which code cloning is not cannot be fixed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Clone Detection'''==&lt;br /&gt;
&lt;br /&gt;
Clone detection finds code in large software systems that has been replicated and modified by hand.&lt;br /&gt;
Remarkably, clone detection works because people copy conceptually identifiable blocks of code, and make only a few changes. This means the same syntax is detectably repeated. Each identified clone thus indicates the presence of a useful problem domain concept, and simultaneously provides an example implementation. Differences between the copies identify parameters or points of variation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Clones can enhance a product line development in a number of ways:&lt;br /&gt;
 &lt;br /&gt;
*Removal of redundant code&lt;br /&gt;
*Lowering maintenance costs&lt;br /&gt;
*Identification of domain concepts for use in the present system or the next&lt;br /&gt;
*Identification of parametrized reusable implementations&lt;br /&gt;
*Sometimes reveal code bugs directly by inspection of parameter bindings with inconsistent actual or conceptual types&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is much hidden knowledge in open source software that can be valuable for improving software quality and productivity. For example, if we want to implement a new feature and know there exists code with similar functionalities in other projects, either reusing the existing code or simply using it for reference will likely shorten development time. Other examples include if a know software fault may occur within a particular context, we can quickly locate all similar defects. To uncover the hidden knowledge, a requisite step is to create an effective code search tool that can scale to the whole open source world, which contains hundreds of billions, even trillions of lines of code. An important aspect of code search is to find copied-and-pasted code or code that looks similar which is code cloning. &lt;br /&gt;
&lt;br /&gt;
Taken the approach that there is much to gain from code clone detection there is a need to compare the effectiveness of clone manipulation when a clone is found.&lt;br /&gt;
&lt;br /&gt;
==Clone Detection Techniques==&lt;br /&gt;
&lt;br /&gt;
===String Based ===&lt;br /&gt;
String based techniques use basic string transformation and comparison algorithms which makes them independent of programming languages. Techniques in this category differ in underlying string comparison algorithm. Comparing calculated signatures per line, is one possibility to identify for matching substrings. Line matching, which comes in two variants, is an alternative which is selected as representative for this category because it uses general string manipulations.&lt;br /&gt;
&lt;br /&gt;
===Simple Line Matching===&lt;br /&gt;
Simple Line Matching is the first variant of line matching in which both detection phases are straightforward. Only minor transformations using string manipulation operations, which can operate using no or very limited knowledge about possible language constructs, are applied. Typical transformations are the removal of empty lines and white spaces. During comparison all lines are compared with each other using a string matching algorithm. This results in a large search space which is usually reduced using hashing buckets. &lt;br /&gt;
&lt;br /&gt;
===Parameterized Line Matching===&lt;br /&gt;
Parameterized Line Matching is another variant of line matching which detects both identical as well as similar code fragments. The idea is that since identifier–names and literals are likely to change when cloning a code fragment, they can be considered as changeable parameters. Therefore, similar fragments which differ only in the naming of these parameters, are allowed.&lt;br /&gt;
&lt;br /&gt;
===Token Based===&lt;br /&gt;
Token based techniques use a more sophisticated transformation algorithm by constructing a token stream from the source code. The presence of such tokens makes it possible to use improved comparison algorithms. Next to parameterized matching with suffix trees, which acts as representative, we include in this category because it also transforms the source code in a token-structure which is afterwards matched. The latter tries to remove much more detail by summarizing non interesting code fragments.&lt;br /&gt;
&lt;br /&gt;
===Parameterized Matching===&lt;br /&gt;
Parameterized Matching With Suffix Trees consists of three consecutive steps manipulating a suffix tree as internal representation. In the first step, a lexical analyser passes over the source text transforming identifiers and literals in parameter symbols, while the typographical structure of each line is encoded in a non-parameter symbol. One symbol always refers to the same identifier, literal or structure. The result of this first step is a parameterized string or p-string.&lt;br /&gt;
Once the p-string is constructed, a criterion to decide whether two sequences in this p-string are a parameterized match or not is necessary. Two strings are a parameterized match if one can be transformed into the other by applying a one-to-one mapping renaming the parameter symbols. An additional encoding prev(S) of the parameter symbols helps us verifying this criterion. In this encoding, each first occurrence of a parameter symbol is replaced by a 0. All later occurrences are replaced by the distance since the previous occurrence of the same symbol. Thus, when two sequences have the same encoding, they are the same except for a systematic renaming of the parameter symbols.&lt;br /&gt;
After the lexical analysis, a data structure called a parameterized suffix tree (p-suffix tree) is built for the pstring. A p-suffix tree is a generalisation of the suffix tree data structure [16] which contains the prev()-encoding of every suffix of a P-string. Concatenating the labels of the arcs on the path from the root to the leaf yields the prev( )-encoding of one suffix. The use of a suffix tree allows a more efficient detection of maximal, parameterized matches.&lt;br /&gt;
&lt;br /&gt;
===Other Techniques===&lt;br /&gt;
AST-based techniques use parsers to first obtain a syntactical representation of the source code, typically an abstract syntax tree (AST). The clone detection algorithms then search for similar subtrees in this AST.&lt;br /&gt;
&lt;br /&gt;
PDG-based approaches  go one step further in obtaining a source code representation of high abstraction. Program dependence graphs (PDGs) contain information of semantically nature, such as control- and data flow of the program.&lt;br /&gt;
&lt;br /&gt;
Metrics-based techniques are related to hashing algorithms. For each fragment of a program the values of a number of metrics is calculated, which are subsequently used to find similar fragments.&lt;br /&gt;
&lt;br /&gt;
==Clone Manipulation==&lt;br /&gt;
So what happens when clone code is? Once the clone detection tools have found code what techniques are available for the tools to solve the issues. The first step is to investigate why the clone code is there. &lt;br /&gt;
&lt;br /&gt;
*Several Questions need to be asked:&lt;br /&gt;
*What classes call the code?&lt;br /&gt;
*What functionality does the code provide?&lt;br /&gt;
*Who “owns” the code?&lt;br /&gt;
*How many systems depend on the code?&lt;br /&gt;
&lt;br /&gt;
Once these questions have been answered and it has been decided that this code cloning needs to be resolved then there are different techniques in solving the code clone issue. There are many tools out there to use for code detection and manipulation. Described below are the different tools researched and some information on the techniques used.&lt;br /&gt;
&lt;br /&gt;
==Clone Dr==&lt;br /&gt;
The CloneDR™ is built with the DMS/Software Reengineering Toolkit. This technology identifies not only exact, but near-miss duplicates in software systems and can be used on a wide variety of languages. Using compiler technology rather than string matching, it will find clones in spite of changed comments, white spaces, line breaks, case changes, different variable names and even different expressions in the clone body. It detects clones in code and/or data declarations. Detected clones can be filtered by size, and automatically or interactively removed. Clones can be removed by replacing them with equivalent preprocessor macros, type declarations, subroutine calls, or inlined subroutine calls (dependent on language and options), without changing the system functionality. The replacement is automatically generated from the detected clones.&lt;br /&gt;
&lt;br /&gt;
==SHINOBI==&lt;br /&gt;
SHINOBI is supported as an Add-In of Microsoft Visual Studio 2005. It automatically detects clones without the programmer's clear intention at the time of opening and editing source code, and constantly displays the detected clones on the view in IDE. SHINOBI displays the detected clones in order of the ranking f the similarity between the source code on the cursor and the detected clones, and the information in the CVS repository, such as message logs and committed dates of the source code that is detected clones.&lt;br /&gt;
&lt;br /&gt;
==CCFinderX==&lt;br /&gt;
CCFinder can be applied to huge source codes. From a source code with approximately a million lines, CCFinder can detect code clones within several minutes to several hours using a PC/AT compatible. By lexical analysis and transformation based on the syntax of the programming languages, CCFinder can extract code clones correctly from source files, even in cases where the names of variables have been changed. CCFinder can run for C/C++, Java, COBOL, Fortran, etc.&lt;br /&gt;
&lt;br /&gt;
*Multi-threading for multi-core CPU   &lt;br /&gt;
*AST-based preprocessing with an island-parser like parser.&lt;br /&gt;
*Search functions&lt;br /&gt;
*Users can adapt the tool to another programming languages or dialects.&lt;br /&gt;
*Analysis using metrics of code clone&lt;br /&gt;
*For interoperability with another tools, the tool can read/write data in tab separated values text format.&lt;br /&gt;
*Interactive analysis with multiple views of GUI front-end GemX.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
There are many different ways to go about code clone detection. Code clones can be detected on an exact match basis. Unfortunately, using exact match criteria for code clone detection may not be sufficient in all cases. For instance, a programmer may copy a particular piece of code, paste it to another location in the system and proceed to change the pasted code such that it remains syntactically similar to the original code, but not exactly similar. Thus, some form of near-exact clone detection must be employed. Parameterized matching (representative for the token-based approaches) provides a precise picture of a given piece of duplicated code and is robust against rename operations. Therefore it works best in combination with fine-grained refactoring tools that work on the level of statements. This is similar to how the refactoring methods of Extract Method, Move Behaviour, Close to Data, and Transform Conditionals into Polymorphism work.&lt;br /&gt;
Although there are different techniques use than the refactoring code methods the software tools seem to work nicely and continue to get better. The tools take a variety of techniques and make them work at an efficient level. As the technology advances the tools will become more and more useful to detect code clone issues.&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29821</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 2 SN</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29821"/>
		<updated>2009-11-22T16:32:49Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Clone Detection and Clone Manipulation'''&lt;br /&gt;
&lt;br /&gt;
=='''Thesis'''==&lt;br /&gt;
The DRY principle says that a particular code fragment should not be repeated more than once in a program. But it happens. And when it does, it is good to be able to find the multiple code &amp;quot;clones.&amp;quot; A variety of tools have been designed for this, and some of them even allow joint editing of the clones. Survey the techniques for dealing with the problem, and compare the effectiveness with refactoring (e.g., Extract Method).&lt;br /&gt;
&lt;br /&gt;
'''Code Cloning'''&lt;br /&gt;
Often in computer systems whether small or large, code can become complex. As systems become larger and larger and more and more people work on the system there are often cases when the code becomes duplicated. Sometimes based on system architecture this is unavoidable. However often times replicated code can be avoided and should be as much as possible. It is always best approach to replace, reuse, and refactor code as much as possible.  &lt;br /&gt;
&lt;br /&gt;
There are times when code cloning is unavoidable. Factors such as design, security restrictions, rights of code, and class interaction can all be factors on why code cannot be manipulated in a way in which code cloning is not cannot be fixed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Clone Detection'''==&lt;br /&gt;
&lt;br /&gt;
Clone detection finds code in large software systems that has been replicated and modified by hand.&lt;br /&gt;
Remarkably, clone detection works because people copy conceptually identifiable blocks of code, and make only a few changes. This means the same syntax is detectably repeated. Each identified clone thus indicates the presence of a useful problem domain concept, and simultaneously provides an example implementation. Differences between the copies identify parameters or points of variation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Clones can enhance a product line development in a number of ways: &lt;br /&gt;
Removal of redundant code&lt;br /&gt;
•	Lowering maintenance costs&lt;br /&gt;
•	Identification of domain concepts for use in the present system or the next&lt;br /&gt;
•	Identification of parameterized reusable implementations&lt;br /&gt;
•	Sometimes reveal code bugs directly by inspection of parameter bindings with inconsistent actual or conceptual types&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is much hidden knowledge in open source software that can be valuable for improving software quality and productivity. For example, if we want to implement a new feature and know there exists code with similar functionalities in other projects, either reusing the existing code or simply using it for reference will likely shorten development time. Other examples include if a know software fault may occur within a particular context, we can quickly locate all similar defects. To uncover the hidden knowledge, a requisite step is to create an effective code search tool that can scale to the whole open source world, which contains hundreds of billions, even trillions of lines of code. An important aspect of code search is to find copied-and-pasted code or code that looks similar which is code cloning. &lt;br /&gt;
&lt;br /&gt;
Taken the approach that there is much to gain from code clone detection there is a need to compare the effectiveness of clone manipulation when a clone is found.&lt;br /&gt;
&lt;br /&gt;
==Clone Detection Techniques==&lt;br /&gt;
&lt;br /&gt;
===String Based ===&lt;br /&gt;
String based techniques use basic string transformation and comparison algorithms which makes them independent of programming languages. Techniques in this category differ in underlying string comparison algorithm. Comparing calculated signatures per line, is one possibility to identify for matching substrings. Line matching, which comes in two variants, is an alternative which is selected as representative for this category because it uses general string manipulations.&lt;br /&gt;
&lt;br /&gt;
===Simple Line Matching===&lt;br /&gt;
Simple Line Matching is the first variant of line matching in which both detection phases are straightforward. Only minor transformations using string manipulation operations, which can operate using no or very limited knowledge about possible language constructs, are applied. Typical transformations are the removal of empty lines and white spaces. During comparison all lines are compared with each other using a string matching algorithm. This results in a large search space which is usually reduced using hashing buckets. &lt;br /&gt;
&lt;br /&gt;
===Parameterized Line Matching===&lt;br /&gt;
Parameterized Line Matching is another variant of line matching which detects both identical as well as similar code fragments. The idea is that since identifier–names and literals are likely to change when cloning a code fragment, they can be considered as changeable parameters. Therefore, similar fragments which differ only in the naming of these parameters, are allowed.&lt;br /&gt;
&lt;br /&gt;
===Token Based===&lt;br /&gt;
Token based techniques use a more sophisticated transformation algorithm by constructing a token stream from the source code. The presence of such tokens makes it possible to use improved comparison algorithms. Next to parameterized matching with suffix trees, which acts as representative, we include in this category because it also transforms the source code in a token-structure which is afterwards matched. The latter tries to remove much more detail by summarizing non interesting code fragments.&lt;br /&gt;
&lt;br /&gt;
===Parameterized Matching===&lt;br /&gt;
Parameterized Matching With Suffix Trees consists of three consecutive steps manipulating a suffix tree as internal representation. In the first step, a lexical analyser passes over the source text transforming identifiers and literals in parameter symbols, while the typographical structure of each line is encoded in a non-parameter symbol. One symbol always refers to the same identifier, literal or structure. The result of this first step is a parameterized string or p-string.&lt;br /&gt;
Once the p-string is constructed, a criterion to decide whether two sequences in this p-string are a parameterized match or not is necessary. Two strings are a parameterized match if one can be transformed into the other by applying a one-to-one mapping renaming the parameter symbols. An additional encoding prev(S) of the parameter symbols helps us verifying this criterion. In this encoding, each first occurrence of a parameter symbol is replaced by a 0. All later occurrences are replaced by the distance since the previous occurrence of the same symbol. Thus, when two sequences have the same encoding, they are the same except for a systematic renaming of the parameter symbols.&lt;br /&gt;
After the lexical analysis, a data structure called a parameterized suffix tree (p-suffix tree) is built for the pstring. A p-suffix tree is a generalisation of the suffix tree data structure [16] which contains the prev()-encoding of every suffix of a P-string. Concatenating the labels of the arcs on the path from the root to the leaf yields the prev( )-encoding of one suffix. The use of a suffix tree allows a more efficient detection of maximal, parameterized matches.&lt;br /&gt;
&lt;br /&gt;
===Other Techniques===&lt;br /&gt;
AST-based techniques use parsers to first obtain a syntactical representation of the source code, typically an abstract syntax tree (AST). The clone detection algorithms then search for similar subtrees in this AST.&lt;br /&gt;
&lt;br /&gt;
PDG-based approaches  go one step further in obtaining a source code representation of high abstraction. Program dependence graphs (PDGs) contain information of semantically nature, such as control- and data flow of the program.&lt;br /&gt;
&lt;br /&gt;
Metrics-based techniques are related to hashing algorithms. For each fragment of a program the values of a number of metrics is calculated, which are subsequently used to find similar fragments.&lt;br /&gt;
&lt;br /&gt;
==Clone Manipulation==&lt;br /&gt;
So what happens when clone code is? Once the clone detection tools have found code what techniques are available for the tools to solve the issues. The first step is to investigate why the clone code is there. &lt;br /&gt;
&lt;br /&gt;
  Several Questions need to be asked:&lt;br /&gt;
  What classes call the code?&lt;br /&gt;
  What functionality does the code provide?&lt;br /&gt;
  Who “owns” the code?&lt;br /&gt;
  How many systems depend on the code?&lt;br /&gt;
&lt;br /&gt;
Once these questions have been answered and it has been decided that this code cloning needs to be resolved then there are different techniques in solving the code clone issue. There are many tools out there to use for code detection and manipulation. Described below are the different tools researched and some information on the techniques used.&lt;br /&gt;
&lt;br /&gt;
==Clone Dr==&lt;br /&gt;
The CloneDR™ is built with the DMS/Software Reengineering Toolkit. This technology identifies not only exact, but near-miss duplicates in software systems and can be used on a wide variety of languages. Using compiler technology rather than string matching, it will find clones in spite of changed comments, white spaces, line breaks, case changes, different variable names and even different expressions in the clone body. It detects clones in code and/or data declarations. Detected clones can be filtered by size, and automatically or interactively removed. Clones can be removed by replacing them with equivalent preprocessor macros, type declarations, subroutine calls, or inlined subroutine calls (dependent on language and options), without changing the system functionality. The replacement is automatically generated from the detected clones.&lt;br /&gt;
&lt;br /&gt;
==SHINOBI==&lt;br /&gt;
SHINOBI is supported as an Add-In of Microsoft Visual Studio 2005. It automatically detects clones without the programmer's clear intention at the time of opening and editing source code, and constantly displays the detected clones on the view in IDE. SHINOBI displays the detected clones in order of the ranking f the similarity between the source code on the cursor and the detected clones, and the information in the CVS repository, such as message logs and committed dates of the source code that is detected clones.&lt;br /&gt;
&lt;br /&gt;
==CCFinderX==&lt;br /&gt;
&lt;br /&gt;
    CCFinder can be applied to huge source codes. From a source code with approximately a million lines, CCFinder can detect code clones within several minutes to several hours using a PC/AT compatible. By lexical analysis and transformation based on the syntax of the programming languages, CCFinder can extract code clones correctly from source files, even in cases where the names of variables have been changed. CCFinder can run for C/C++, Java, COBOL, Fortran, etc.&lt;br /&gt;
&lt;br /&gt;
  •	Multi-threading for multi-core CPU   &lt;br /&gt;
  •	AST-based preprocessing with an island-parser like parser.&lt;br /&gt;
  •	Search functions&lt;br /&gt;
  •	Users can adapt the tool to another programming languages or dialects.&lt;br /&gt;
  •	Analysis using metrics of code clone&lt;br /&gt;
  •	For interoperability with another tools, the tool can read/write data in tab separated values text format.&lt;br /&gt;
  •	Interactive analysis with multiple views of GUI front-end GemX.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
There are many different ways to go about code clone detection. Code clones can be detected on an exact match basis. Unfortunately, using exact match criteria for code clone detection may not be sufficient in all cases. For instance, a programmer may copy a particular piece of code, paste it to another location in the system and proceed to change the pasted code such that it remains syntactically similar to the original code, but not exactly similar. Thus, some form of near-exact clone detection must be employed. Parameterized matching (representative for the token-based approaches) provides a precise picture of a given piece of duplicated code and is robust against rename operations. Therefore it works best in combination with fine-grained refactoring tools that work on the level of statements. This is similar to how the refactoring methods of Extract Method, Move Behaviour, Close to Data, and Transform Conditionals into Polymorphism work.&lt;br /&gt;
Although there are different techniques use than the refactoring code methods the software tools seem to work nicely and continue to get better. The tools take a variety of techniques and make them work at an efficient level. As the technology advances the tools will become more and more useful to detect code clone issues.&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29820</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 2 SN</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29820"/>
		<updated>2009-11-22T16:26:50Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Clone Detection and Clone Manipulation'''&lt;br /&gt;
&lt;br /&gt;
=='''Thesis'''==&lt;br /&gt;
The DRY principle says that a particular code fragment should not be repeated more than once in a program. But it happens. And when it does, it is good to be able to find the multiple code &amp;quot;clones.&amp;quot; A variety of tools have been designed for this, and some of them even allow joint editing of the clones. Survey the techniques for dealing with the problem, and compare the effectiveness with refactoring (e.g., Extract Method).&lt;br /&gt;
&lt;br /&gt;
'''Code Cloning'''&lt;br /&gt;
Often in computer systems whether small or large, code can become complex. As systems become larger and larger and more and more people work on the system there are often cases when the code becomes duplicated. Sometimes based on system architecture this is unavoidable. However often times replicated code can be avoided and should be as much as possible. It is always best approach to replace, reuse, and refactor code as much as possible.  &lt;br /&gt;
&lt;br /&gt;
There are times when code cloning is unavoidable. Factors such as design, security restrictions, rights of code, and class interaction can all be factors on why code cannot be manipulated in a way in which code cloning is not cannot be fixed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Clone Detection'''==&lt;br /&gt;
&lt;br /&gt;
Clone detection finds code in large software systems that has been replicated and modified by hand.&lt;br /&gt;
Remarkably, clone detection works because people copy conceptually identifiable blocks of code, and make only a few changes. This means the same syntax is detectably repeated. Each identified clone thus indicates the presence of a useful problem domain concept, and simultaneously provides an example implementation. Differences between the copies identify parameters or points of variation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Clones can enhance a product line development in a number of ways: &lt;br /&gt;
Removal of redundant code&lt;br /&gt;
•	Lowering maintenance costs&lt;br /&gt;
•	Identification of domain concepts for use in the present system or the next&lt;br /&gt;
•	Identification of parameterized reusable implementations&lt;br /&gt;
•	Sometimes reveal code bugs directly by inspection of parameter bindings with inconsistent actual or conceptual types&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is much hidden knowledge in open source software that can be valuable for improving software quality and productivity. For example, if we want to implement a new feature and know there exists code with similar functionalities in other projects, either reusing the existing code or simply using it for reference will likely shorten development time. Other examples include if a know software fault may occur within a particular context, we can quickly locate all similar defects. To uncover the hidden knowledge, a requisite step is to create an effective code search tool that can scale to the whole open source world, which contains hundreds of billions, even trillions of lines of code. An important aspect of code search is to find copied-and-pasted code or code that looks similar which is code cloning. &lt;br /&gt;
&lt;br /&gt;
Taken the approach that there is much to gain from code clone detection there is a need to compare the effectiveness of clone manipulation when a clone is found.&lt;br /&gt;
&lt;br /&gt;
==Clone Detection Techniques==&lt;br /&gt;
&lt;br /&gt;
===String Based ===&lt;br /&gt;
String based techniques use basic string transformation and comparison algorithms which makes them independent of programming languages. Techniques in this category differ in underlying string comparison algorithm. Comparing calculated signatures per line, is one possibility to identify for matching substrings. Line matching, which comes in two variants, is an alternative which is selected as representative for this category because it uses general string manipulations.&lt;br /&gt;
&lt;br /&gt;
===Simple Line Matching===&lt;br /&gt;
Simple Line Matching is the first variant of line matching in which both detection phases are straightforward. Only minor transformations using string manipulation operations, which can operate using no or very limited knowledge about possible language constructs, are applied. Typical transformations are the removal of empty lines and white spaces. During comparison all lines are compared with each other using a string matching algorithm. This results in a large search space which is usually reduced using hashing buckets. &lt;br /&gt;
&lt;br /&gt;
===Parameterized Line Matching===&lt;br /&gt;
Parameterized Line Matching is another variant of line matching which detects both identical as well as similar code fragments. The idea is that since identifier–names and literals are likely to change when cloning a code fragment, they can be considered as changeable parameters. Therefore, similar fragments which differ only in the naming of these parameters, are allowed.&lt;br /&gt;
&lt;br /&gt;
===Token Based===&lt;br /&gt;
Token based techniques use a more sophisticated transformation algorithm by constructing a token stream from the source code. The presence of such tokens makes it possible to use improved comparison algorithms. Next to parameterized matching with suffix trees, which acts as representative, we include in this category because it also transforms the source code in a token-structure which is afterwards matched. The latter tries to remove much more detail by summarizing non interesting code fragments.&lt;br /&gt;
&lt;br /&gt;
Parameterized Matching&lt;br /&gt;
Parameterized Matching With Suffix Trees consists of three consecutive steps manipulating a suffix tree as internal representation. In the first step, a lexical analyser passes over the source text transforming identifiers and literals in parameter symbols, while the typographical structure of each line is encoded in a non-parameter symbol. One symbol always refers to the same identifier, literal or structure. The result of this first step is a parameterized string or p-string.&lt;br /&gt;
Once the p-string is constructed, a criterion to decide whether two sequences in this p-string are a parameterized match or not is necessary. Two strings are a parameterized match if one can be transformed into the other by applying a one-to-one mapping renaming the parameter symbols. An additional encoding prev(S) of the parameter symbols helps us verifying this criterion. In this encoding, each first occurrence of a parameter symbol is replaced by a 0. All later occurrences are replaced by the distance since the previous occurrence of the same symbol. Thus, when two sequences have the same encoding, they are the same except for a systematic renaming of the parameter symbols.&lt;br /&gt;
After the lexical analysis, a data structure called a parameterized suffix tree (p-suffix tree) is built for the pstring. A p-suffix tree is a generalisation of the suffix tree data structure [16] which contains the prev()-encoding of every suffix of a P-string. Concatenating the labels of the arcs on the path from the root to the leaf yields the prev( )-encoding of one suffix. The use of a suffix tree allows a more efficient detection of maximal, parameterized matches.&lt;br /&gt;
&lt;br /&gt;
Other Techniques&lt;br /&gt;
AST-based techniques use parsers to first obtain a syntactical representation of the source code, typically an abstract syntax tree (AST). The clone detection algorithms then search for similar subtrees in this AST.&lt;br /&gt;
PDG-based approaches  go one step further in obtaining a source code representation of high abstraction. Program dependence graphs (PDGs) contain information of semantically nature, such as control- and data flow of the program.&lt;br /&gt;
Metrics-based techniques are related to hashing algorithms. For each fragment of a program the values of a number of metrics is calculated, which are subsequently used to find similar fragments.&lt;br /&gt;
&lt;br /&gt;
Clone Manipulation&lt;br /&gt;
So what happens when clone code is? Once the clone detection tools have found code what techniques are available for the tools to solve the issues. The first step is to investigate why the clone code is there. &lt;br /&gt;
Several Questions need to be asked:&lt;br /&gt;
What classes call the code?&lt;br /&gt;
What functionality does the code provide?&lt;br /&gt;
Who “owns” the code?&lt;br /&gt;
How many systems depend on the code?&lt;br /&gt;
Once these questions have been answered and it has been decided that this code cloning needs to be resolved then there are different techniques in solving the code clone issue. There are many tools out there to use for code detection and manipulation. Described below are the different tools researched and some information on the techniques used.&lt;br /&gt;
&lt;br /&gt;
Clone Dr&lt;br /&gt;
The CloneDR™ is built with the DMS/Software Reengineering Toolkit. This technology identifies not only exact, but near-miss duplicates in software systems and can be used on a wide variety of languages. Using compiler technology rather than string matching, it will find clones in spite of changed comments, white spaces, line breaks, case changes, different variable names and even different expressions in the clone body. It detects clones in code and/or data declarations. Detected clones can be filtered by size, and automatically or interactively removed. Clones can be removed by replacing them with equivalent preprocessor macros, type declarations, subroutine calls, or inlined subroutine calls (dependent on language and options), without changing the system functionality. The replacement is automatically generated from the detected clones.&lt;br /&gt;
&lt;br /&gt;
SHINOBI&lt;br /&gt;
SHINOBI is supported as an Add-In of Microsoft Visual Studio 2005. It automatically detects clones without the programmer's clear intention at the time of opening and editing source code, and constantly displays the detected clones on the view in IDE. SHINOBI displays the detected clones in order of the ranking f the similarity between the source code on the cursor and the detected clones, and the information in the CVS repository, such as message logs and committed dates of the source code that is detected clones&lt;br /&gt;
CCFinderX&lt;br /&gt;
    CCFinder can be applied to huge source codes. From a source code with approximately a million lines, CCFinder can detect code clones within several minutes to several hours using a PC/AT compatible. By lexical analysis and transformation based on the syntax of the programming languages, CCFinder can extract code clones correctly from source files, even in cases where the names of variables have been changed. CCFinder can run for C/C++, Java, COBOL, Fortran, etc.&lt;br /&gt;
•	Multi-threading for multi-core CPU &lt;br /&gt;
•	AST-based preprocessing with an island-parser like parser.&lt;br /&gt;
•	Search functions&lt;br /&gt;
•	Users can adapt the tool to another programming languages or dialects.&lt;br /&gt;
•	Analysis using metrics of code clone&lt;br /&gt;
•	For interoperability with another tools, the tool can read/write data in tab separated values text format.&lt;br /&gt;
•	Interactive analysis with multiple views of GUI front-end GemX.&lt;br /&gt;
&lt;br /&gt;
Conclusion&lt;br /&gt;
There are many different ways to go about code clone detection. Code clones can be detected on an exact match basis. Unfortunately, using exact match criteria for code clone detection may not be sufficient in all cases. For instance, a programmer may copy a particular piece of code, paste it to another location in the system and proceed to change the pasted code such that it remains syntactically similar to the original code, but not exactly similar. Thus, some form of near-exact clone detection must be employed. Parameterized matching (representative for the token-based approaches) provides a precise picture of a given piece of duplicated code and is robust against rename operations. Therefore it works best in combination with fine-grained refactoring tools that work on the level of statements. This is similar to how the refactoring methods of Extract Method, Move Behaviour, Close to Data, and Transform Conditionals into Polymorphism work.&lt;br /&gt;
Although there are different techniques use than the refactoring code methods the software tools seem to work nicely and continue to get better. The tools take a variety of techniques and make them work at an efficient level. As the technology advances the tools will become more and more useful to detect code clone issues.&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29819</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 2 SN</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_2_SN&amp;diff=29819"/>
		<updated>2009-11-22T16:23:07Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Clone Detection and Clone Manipulation&lt;br /&gt;
The DRY principle says that a particular code fragment should not be repeated more than once in a program. But it happens. And when it does, it is good to be able to find the multiple code &amp;quot;clones.&amp;quot; A variety of tools have been designed for this, and some of them even allow joint editing of the clones. Survey the techniques for dealing with the problem, and compare the effectiveness with refactoring (e.g., Extract Method).&lt;br /&gt;
Code Cloning&lt;br /&gt;
Often in computer systems whether small or large, code can become complex. As systems become larger and larger and more and more people work on the system there are often cases when the code becomes duplicated. Sometimes based on system architecture this is unavoidable. However often times replicated code can be avoided and should be as much as possible. It is always best approach to replace, reuse, and refactor code as much as possible.  &lt;br /&gt;
There are times when code cloning is unavoidable. Factors such as design, security restrictions, rights of code, and class interaction can all be factors on why code cannot be manipulated in a way in which code cloning is not cannot be fixed. &lt;br /&gt;
Clone Detection&lt;br /&gt;
Clone detection finds code in large software systems that has been replicated and modified by hand.&lt;br /&gt;
Remarkably, clone detection works because people copy conceptually identifiable blocks of code, and make only a few changes. This means the same syntax is detectably repeated. Each identified clone thus indicates the presence of a useful problem domain concept, and simultaneously provides an example implementation. Differences between the copies identify parameters or points of variation.&lt;br /&gt;
Clones can enhance a product line development in a number of ways: &lt;br /&gt;
•	Removal of redundant code&lt;br /&gt;
•	Lowering maintenance costs&lt;br /&gt;
•	Identification of domain concepts for use in the present system or the next&lt;br /&gt;
•	Identification of parameterized reusable implementations&lt;br /&gt;
•	Sometimes reveal code bugs directly by inspection of parameter bindings with inconsistent actual or conceptual types&lt;br /&gt;
&lt;br /&gt;
There is much hidden knowledge in open source software that can be valuable for improving software quality and productivity. For example, if we want to implement a new feature and know there exists code with similar functionalities in other projects, either reusing the existing code or simply using it for reference will likely shorten development time. Other examples include if a know software fault may occur within a particular context, we can quickly locate all similar defects. To uncover the hidden knowledge, a requisite step is to create an effective code search tool that can scale to the whole open source world, which contains hundreds of billions, even trillions of lines of code. An important aspect of code search is to find copied-and-pasted code or code that looks similar which is code cloning. &lt;br /&gt;
Taken the approach that there is much to gain from code clone detection there is a need to compare the effectiveness of clone manipulation when a clone is found.&lt;br /&gt;
&lt;br /&gt;
Clone Detection Techniques&lt;br /&gt;
String Based &lt;br /&gt;
String based techniques use basic string transformation and comparison algorithms which makes them independent of programming languages. Techniques in this category differ in underlying string comparison algorithm. Comparing calculated signatures per line, is one possibility to identify for matching substrings. Line matching, which comes in two variants, is an alternative which is selected as representative for this category because it uses general string manipulations.&lt;br /&gt;
Simple Line Matching&lt;br /&gt;
Simple Line Matching is the first variant of line matching in which both detection phases are straightforward. Only minor transformations using string manipulation operations, which can operate using no or very limited knowledge about possible language constructs, are applied. Typical transformations are the removal of empty lines and white spaces. During comparison all lines are compared with each other using a string matching algorithm. This results in a large search space which is usually reduced using hashing buckets. &lt;br /&gt;
Parameterized Line Matching&lt;br /&gt;
Parameterized Line Matching is another variant of line matching which detects both identical as well as similar code fragments. The idea is that since identifier–names and literals are likely to change when cloning a code fragment, they can be considered as changeable parameters. Therefore, similar fragments which differ only in the naming of these parameters, are allowed.&lt;br /&gt;
&lt;br /&gt;
Token Based&lt;br /&gt;
Token based techniques use a more sophisticated transformation algorithm by constructing a token stream from the source code. The presence of such tokens makes it possible to use improved comparison algorithms. Next to parameterized matching with suffix trees, which acts as representative, we include in this category because it also transforms the source code in a token-structure which is afterwards matched. The latter tries to remove much more detail by summarizing non interesting code fragments.&lt;br /&gt;
Parameterized Matching&lt;br /&gt;
Parameterized Matching With Suffix Trees consists of three consecutive steps manipulating a suffix tree as internal representation. In the first step, a lexical analyser passes over the source text transforming identifiers and literals in parameter symbols, while the typographical structure of each line is encoded in a non-parameter symbol. One symbol always refers to the same identifier, literal or structure. The result of this first step is a parameterized string or p-string.&lt;br /&gt;
Once the p-string is constructed, a criterion to decide whether two sequences in this p-string are a parameterized match or not is necessary. Two strings are a parameterized match if one can be transformed into the other by applying a one-to-one mapping renaming the parameter symbols. An additional encoding prev(S) of the parameter symbols helps us verifying this criterion. In this encoding, each first occurrence of a parameter symbol is replaced by a 0. All later occurrences are replaced by the distance since the previous occurrence of the same symbol. Thus, when two sequences have the same encoding, they are the same except for a systematic renaming of the parameter symbols.&lt;br /&gt;
After the lexical analysis, a data structure called a parameterized suffix tree (p-suffix tree) is built for the pstring. A p-suffix tree is a generalisation of the suffix tree data structure [16] which contains the prev()-encoding of every suffix of a P-string. Concatenating the labels of the arcs on the path from the root to the leaf yields the prev( )-encoding of one suffix. The use of a suffix tree allows a more efficient detection of maximal, parameterized matches.&lt;br /&gt;
&lt;br /&gt;
Other Techniques&lt;br /&gt;
AST-based techniques use parsers to first obtain a syntactical representation of the source code, typically an abstract syntax tree (AST). The clone detection algorithms then search for similar subtrees in this AST.&lt;br /&gt;
PDG-based approaches  go one step further in obtaining a source code representation of high abstraction. Program dependence graphs (PDGs) contain information of semantically nature, such as control- and data flow of the program.&lt;br /&gt;
Metrics-based techniques are related to hashing algorithms. For each fragment of a program the values of a number of metrics is calculated, which are subsequently used to find similar fragments.&lt;br /&gt;
&lt;br /&gt;
Clone Manipulation&lt;br /&gt;
So what happens when clone code is? Once the clone detection tools have found code what techniques are available for the tools to solve the issues. The first step is to investigate why the clone code is there. &lt;br /&gt;
Several Questions need to be asked:&lt;br /&gt;
What classes call the code?&lt;br /&gt;
What functionality does the code provide?&lt;br /&gt;
Who “owns” the code?&lt;br /&gt;
How many systems depend on the code?&lt;br /&gt;
Once these questions have been answered and it has been decided that this code cloning needs to be resolved then there are different techniques in solving the code clone issue. There are many tools out there to use for code detection and manipulation. Described below are the different tools researched and some information on the techniques used.&lt;br /&gt;
&lt;br /&gt;
Clone Dr&lt;br /&gt;
The CloneDR™ is built with the DMS/Software Reengineering Toolkit. This technology identifies not only exact, but near-miss duplicates in software systems and can be used on a wide variety of languages. Using compiler technology rather than string matching, it will find clones in spite of changed comments, white spaces, line breaks, case changes, different variable names and even different expressions in the clone body. It detects clones in code and/or data declarations. Detected clones can be filtered by size, and automatically or interactively removed. Clones can be removed by replacing them with equivalent preprocessor macros, type declarations, subroutine calls, or inlined subroutine calls (dependent on language and options), without changing the system functionality. The replacement is automatically generated from the detected clones.&lt;br /&gt;
&lt;br /&gt;
SHINOBI&lt;br /&gt;
SHINOBI is supported as an Add-In of Microsoft Visual Studio 2005. It automatically detects clones without the programmer's clear intention at the time of opening and editing source code, and constantly displays the detected clones on the view in IDE. SHINOBI displays the detected clones in order of the ranking f the similarity between the source code on the cursor and the detected clones, and the information in the CVS repository, such as message logs and committed dates of the source code that is detected clones&lt;br /&gt;
CCFinderX&lt;br /&gt;
    CCFinder can be applied to huge source codes. From a source code with approximately a million lines, CCFinder can detect code clones within several minutes to several hours using a PC/AT compatible. By lexical analysis and transformation based on the syntax of the programming languages, CCFinder can extract code clones correctly from source files, even in cases where the names of variables have been changed. CCFinder can run for C/C++, Java, COBOL, Fortran, etc.&lt;br /&gt;
•	Multi-threading for multi-core CPU &lt;br /&gt;
•	AST-based preprocessing with an island-parser like parser.&lt;br /&gt;
•	Search functions&lt;br /&gt;
•	Users can adapt the tool to another programming languages or dialects.&lt;br /&gt;
•	Analysis using metrics of code clone&lt;br /&gt;
•	For interoperability with another tools, the tool can read/write data in tab separated values text format.&lt;br /&gt;
•	Interactive analysis with multiple views of GUI front-end GemX.&lt;br /&gt;
&lt;br /&gt;
Conclusion&lt;br /&gt;
There are many different ways to go about code clone detection. Code clones can be detected on an exact match basis. Unfortunately, using exact match criteria for code clone detection may not be sufficient in all cases. For instance, a programmer may copy a particular piece of code, paste it to another location in the system and proceed to change the pasted code such that it remains syntactically similar to the original code, but not exactly similar. Thus, some form of near-exact clone detection must be employed. Parameterized matching (representative for the token-based approaches) provides a precise picture of a given piece of duplicated code and is robust against rename operations. Therefore it works best in combination with fine-grained refactoring tools that work on the level of statements. This is similar to how the refactoring methods of Extract Method, Move Behaviour, Close to Data, and Transform Conditionals into Polymorphism work.&lt;br /&gt;
Although there are different techniques use than the refactoring code methods the software tools seem to work nicely and continue to get better. The tools take a variety of techniques and make them work at an efficient level. As the technology advances the tools will become more and more useful to detect code clone issues.&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_22_SN&amp;diff=29774</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 22 SN</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_22_SN&amp;diff=29774"/>
		<updated>2009-11-19T19:55:41Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Clone Detection and Clone Manipulation&lt;br /&gt;
The DRY principle says that a particular code fragment should not be repeated more than once in a program. But it happens. And when it does, it is good to be able to find the multiple code &amp;quot;clones.&amp;quot; A variety of tools have been designed for this, and some of them even allow joint editing of the clones. Survey the techniques for dealing with the problem, and compare the effectiveness with refactoring (e.g., Extract Method).&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19700</id>
		<title>CSC/ECE 517 Fall 2009/wiki1a 2 sn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19700"/>
		<updated>2009-09-17T12:16:27Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: /* '''Why Mock?''' */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Comparison of Mock Frameworks ==&lt;br /&gt;
&lt;br /&gt;
When performing tests, it's convenient to have the objects be in a particular configuration, so that boundary cases can be tested.  Setting up the objects can sometimes be complicated. There are different Mock Frameworks out in the development community that can be used to develop these tests. This page attempts to define and compare these different types of [http://en.wikipedia.org/wiki/Framework frameworks].&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. A computer programmer typically creates a mock object to test the behavior of some other object, in much the same way that a car designer uses a crash test dummy to simulate the dynamic behavior of a human in vehicle impacts. [http://en.wikipedia.org/wiki/Mock_object 3]&lt;br /&gt;
&lt;br /&gt;
Mock frameworks are the environments that are available to create these mock objects and mock tests. &lt;br /&gt;
There are many different types of frameworks for different platforms. They are a set of programmable [http://en.wikipedia.org/wiki/Application_programming_interface APIs] that allow creation of mock and stub objects in relative easy fashion. Mock frameworks save the developer from the need to write repetitive code to test or simulate object interactions.&lt;br /&gt;
&lt;br /&gt;
== Concepts ==&lt;br /&gt;
&lt;br /&gt;
==='''Why Mock?'''===&lt;br /&gt;
&lt;br /&gt;
*The concept behind mock objects is that there is a need to create an object that will take the place of the real object. This mock object will expect a certain method to be called with certain parameters and when that happens, it will return an expected result. When writing units tests for a class that would normally use the real object, we can instead supply it with a mock object. This allows us a new level of flexibility in testing.[http://www.michaelminella.com/testing/the-concept-of-mocking.html 1]&lt;br /&gt;
&lt;br /&gt;
*Ease of modifying the mock object during separate tests to get it to get it to return a range of different data. Test can pass in valid, invalid, and extreme ranges to test how the code calling it handles such situations.[http://www.michaelminella.com/testing/the-concept-of-mocking.html 1]&lt;br /&gt;
&lt;br /&gt;
*Simulation of failures, such as the inability to connect to a database, to test the failure mode of classes.&lt;br /&gt;
&lt;br /&gt;
*Encourages better structured tests and, more importantly, improved domain code by preserving encapsulation, reducing dependencies and clarifying the interactions between classes. A running [http://en.wikipedia.org/wiki/Object-oriented_programming Object-Oriented program] is a web of objects that collaborate by calling methods on each other. There sometimes can be many dependencies that have to be met in order to call certain objects. To make the complex dependencies be easily testable, mock objects are created in order to “mock” the stages that the object needs to be in, in order to call upon another object.&lt;br /&gt;
&lt;br /&gt;
*Often times in programming, only the changes in state of an object are tested. This would be acceptable only if there was one object. However, many real world applications contain hundreds upon hundreds of different objects. Mock objects have changed the focus of test from thinking about the changes in state of an object to thinking about its interactions with other objects.[http://msdn.microsoft.com/en-us/magazine/dd882516.aspx 2]&lt;br /&gt;
&lt;br /&gt;
==='''Different Types'''===&lt;br /&gt;
&lt;br /&gt;
====Proxy====&lt;br /&gt;
A proxy object is an object that is used to take the place of a real object. This is the original concept for all mock frameworks. In the case of mock objects, a proxy object is used to imitate the real object your code is dependent on. The proxy object is created with the mocking framework, and then set it on the object using either a setter or constructor. One has to be able to set the dependency up through an external means. This is one of the reasons Dependency Injection frameworks like [http://en.wikipedia.org/wiki/Spring_Framework Java Spring] have increase in popularity because they allow the ability to inject the proxy objects without modifying code.&lt;br /&gt;
[http://www.carlosble.com/?p=348 Proxy]&lt;br /&gt;
&lt;br /&gt;
====Class Remapping====&lt;br /&gt;
The second form of mocking is to remap the class file in the class loader. The concept is relatively new and is provided by the new java.lang.Instrument class. The basic idea is that the framework tells the class loader to remap the reference to another class file it will load which will be the mocked class. This allows one to be able to mock objects that are created by using the new operator much like other Object Oriented languages. Although this approach provides more functionality than the proxy object approach, it is much more complex and harder to write and fully understand.&lt;br /&gt;
[http://download.oracle.com/docs/cd/E13189_01/kodo/docs324/ref_guide_mapping_classmapping.html Class Mapping]&lt;br /&gt;
&lt;br /&gt;
== Examples of Mocking ==&lt;br /&gt;
&lt;br /&gt;
Lets say you have a an interface that looks like this:&lt;br /&gt;
&lt;br /&gt;
  public interface FileInterface &lt;br /&gt;
  {&lt;br /&gt;
    public void openFile(String filename) ;&lt;br /&gt;
    public void closeFile() ;&lt;br /&gt;
    public String readFile() ;    &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Then you have a class that looks like this:&lt;br /&gt;
&lt;br /&gt;
  public class FileManipulator implements FileInterface &lt;br /&gt;
  {&lt;br /&gt;
    private BufferedReader in;&lt;br /&gt;
    private boolean error = false; &lt;br /&gt;
    public void openFile(String filename) &lt;br /&gt;
    {&lt;br /&gt;
      try &lt;br /&gt;
      {&lt;br /&gt;
        in = new BufferedReader(new FileReader(filename));&lt;br /&gt;
      } catch (FileNotFoundException e) {}&lt;br /&gt;
    }&lt;br /&gt;
    public void closeFile() &lt;br /&gt;
    {&lt;br /&gt;
      try &lt;br /&gt;
      {&lt;br /&gt;
        in.close();&lt;br /&gt;
      } catch (IOException e) {}&lt;br /&gt;
    }&lt;br /&gt;
    public String readFile() &lt;br /&gt;
    {&lt;br /&gt;
      String s;&lt;br /&gt;
      try &lt;br /&gt;
      {&lt;br /&gt;
        s = in.readLine();&lt;br /&gt;
      } catch (IOException e) {}&lt;br /&gt;
    &lt;br /&gt;
     return s;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
The Mock File would look something like this:&lt;br /&gt;
&lt;br /&gt;
  public class MockFileManipulator implements FileInterface &lt;br /&gt;
  {&lt;br /&gt;
    private boolean initialized = false; &lt;br /&gt;
    private boolean error = false; &lt;br /&gt;
    private String filename;&lt;br /&gt;
    public void openFile(String filename) &lt;br /&gt;
    {&lt;br /&gt;
      if (filename == null || filename.equals(&amp;quot;&amp;quot;)) &lt;br /&gt;
      {&lt;br /&gt;
        Assert.fail(&amp;quot;Name of file is either null or blank&amp;quot;);&lt;br /&gt;
      }  &lt;br /&gt;
      this.filename = filename;&lt;br /&gt;
      initialized = true; &lt;br /&gt;
    }&lt;br /&gt;
    public void closeFile() &lt;br /&gt;
    {&lt;br /&gt;
      if (!initialized) &lt;br /&gt;
      { &lt;br /&gt;
        Assert.fail(&amp;quot;Trying to close before open&amp;quot;);&lt;br /&gt;
      }  &lt;br /&gt;
    }&lt;br /&gt;
    public String readFile() &lt;br /&gt;
    {&lt;br /&gt;
      if (!initialized) &lt;br /&gt;
      { &lt;br /&gt;
        Assert.fail(&amp;quot;Trying to read before open&amp;quot;);&lt;br /&gt;
        return null;&lt;br /&gt;
      } &lt;br /&gt;
      if (filename.equals(&amp;quot;readerror&amp;quot;)) &lt;br /&gt;
      { &lt;br /&gt;
        error = true;&lt;br /&gt;
        return &amp;quot;&amp;quot;;&lt;br /&gt;
      } &lt;br /&gt;
      return null; &lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Then when you have a test class or the class that you use the FileManipulator class, instead of:&lt;br /&gt;
&lt;br /&gt;
 FileManipulator fileChanger = new FileManipulator ();&lt;br /&gt;
 fileChanger.openFile(&amp;quot;MyTestFile.txt&amp;quot;)&lt;br /&gt;
 fileChanger.readFile();&lt;br /&gt;
 fileChanger.closeFile();&lt;br /&gt;
&lt;br /&gt;
Use the MockFileManipulator constructor to define the data object.&lt;br /&gt;
&lt;br /&gt;
 MockFileManipulator fileChanger = new MockFileManipulator ();&lt;br /&gt;
 fileChanger.openFile(&amp;quot;MyTestFile.txt&amp;quot;)&lt;br /&gt;
 fileChanger.readFile();&lt;br /&gt;
 fileChanger.closeFile();&lt;br /&gt;
&lt;br /&gt;
== Comparison of Different Systems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''EasyMock'''===&lt;br /&gt;
*EasyMock has been the first dynamic Mock Object generator, relieving users of hand-writing Mock Objects, or generating code for them.&lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Supports re-factoring-safe Mock Objects&lt;br /&gt;
*Ability to return values and exceptions.&lt;br /&gt;
*Method order checking&lt;br /&gt;
http://easymock.org/&lt;br /&gt;
&lt;br /&gt;
==='''MOQ'''===&lt;br /&gt;
*Moq is the only mocking library for .NET developed from scratch to take full advantage of .NET 3.5 and C# 3.0 features.&lt;br /&gt;
*Supports mocking interfaces as well as classes. &lt;br /&gt;
*Supports the overriding of expectations where the test can set default expectations in a fixture setup, and override as needed on certain tests&lt;br /&gt;
*Intercept and raise events on mocks&lt;br /&gt;
http://code.google.com/p/moq/.&lt;br /&gt;
&lt;br /&gt;
==='''NMock'''===&lt;br /&gt;
*NMock is a dynamic mock object library for .NET. &lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Allows expectations to be defined and fails the test if any expectations are violated&lt;br /&gt;
*Expectations are specified beforehand and verified on the fly as the code under test is being executed, rather than afterward using assertions&lt;br /&gt;
*Implementations of interfaces are generate on the fly at runtime&lt;br /&gt;
http://www.nmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Rhino Mocks'''===&lt;br /&gt;
*Only supports mocks of interfaces, delegates and classes, including those with parametrized constructors.&lt;br /&gt;
*Expectations on the called methods by using strongly typed mocks instead of strings.&lt;br /&gt;
*Recursive mocking&lt;br /&gt;
http://ayende.com/projects/rhino-mocks.aspx&lt;br /&gt;
&lt;br /&gt;
==='''jMock'''===&lt;br /&gt;
*Forces test to be explicit about the argument values that will be passed to the expected methods&lt;br /&gt;
*Ability to write custom stubs, constraints, and Invocation Matchers&lt;br /&gt;
*Works well with the auto completion and refactoring features of your IDE&lt;br /&gt;
http://www.jmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Mocha'''===&lt;br /&gt;
*Similar to jMock only for Ruby &lt;br /&gt;
*Supports testing frameworks: Test::Unit, RSpec, test/spec, expectations, Dust, MiniTest and JtestR.&lt;br /&gt;
http://mocha.rubyforge.org/&lt;br /&gt;
&lt;br /&gt;
==='''Test::MockObject'''===&lt;br /&gt;
*Similar to jMock only for Perl&lt;br /&gt;
*Simple testing techniques&lt;br /&gt;
http://search.cpan.org/dist/Test-MockObject/lib/Test/MockObject.pm&lt;br /&gt;
&lt;br /&gt;
==='''JMockit'''===&lt;br /&gt;
&lt;br /&gt;
*Simpler and more succinct APIs for writing tests with behavior verification or state verification&lt;br /&gt;
*Provides other tools for supporting the creation of large test suites&lt;br /&gt;
*Uses class remapping instead of the original proxy dependencies&lt;br /&gt;
https://jmockit.dev.java.net/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
A mock object framework can make sure that the method under test, when executed, will in fact call certain functions on the mock object  and that the method under test will react in an appropriate way to whatever the mock objects do. Most parts of a software system do not work in isolation, but collaborate with other parts to get their job done. Writing tests provides a framework to think about functionality, Mock Objects provides a framework for making assertions about those relationships and for simulating responses. Mock Objects also allows programmers to make their tests only as precise as they need to be.&lt;br /&gt;
&lt;br /&gt;
The different frameworks provide a myriad of options for software developers to produce the correct mock tests for their software. The more complex the system, the more important it is when selecting the mock framework. Support for the framework is essential as well. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
1. [http://www.sizovpoint.com/2009/03/java-mock-frameworks-comparison.html Java Mock Framework Comparisons]&lt;br /&gt;
&lt;br /&gt;
2. [http://msdn.microsoft.com/en-us/magazine/dd882516.aspx Using Mocks And Tests To Design Role-Based Objects]&lt;br /&gt;
&lt;br /&gt;
3. [http://en.wikipedia.org/wiki/Mock_object Wikipedia - Mock object]&lt;br /&gt;
&lt;br /&gt;
4. [http://javaboutique.internet.com/tutorials/mock_objects/ Java Mock Objects]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19698</id>
		<title>CSC/ECE 517 Fall 2009/wiki1a 2 sn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19698"/>
		<updated>2009-09-17T12:15:54Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: /* Definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Comparison of Mock Frameworks ==&lt;br /&gt;
&lt;br /&gt;
When performing tests, it's convenient to have the objects be in a particular configuration, so that boundary cases can be tested.  Setting up the objects can sometimes be complicated. There are different Mock Frameworks out in the development community that can be used to develop these tests. This page attempts to define and compare these different types of [http://en.wikipedia.org/wiki/Framework frameworks].&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. A computer programmer typically creates a mock object to test the behavior of some other object, in much the same way that a car designer uses a crash test dummy to simulate the dynamic behavior of a human in vehicle impacts. [http://en.wikipedia.org/wiki/Mock_object 3]&lt;br /&gt;
&lt;br /&gt;
Mock frameworks are the environments that are available to create these mock objects and mock tests. &lt;br /&gt;
There are many different types of frameworks for different platforms. They are a set of programmable [http://en.wikipedia.org/wiki/Application_programming_interface APIs] that allow creation of mock and stub objects in relative easy fashion. Mock frameworks save the developer from the need to write repetitive code to test or simulate object interactions.&lt;br /&gt;
&lt;br /&gt;
== Concepts ==&lt;br /&gt;
&lt;br /&gt;
==='''Why Mock?'''===&lt;br /&gt;
&lt;br /&gt;
*The concept behind mock objects is that there is a need to create an object that will take the place of the real object. This mock object will expect a certain method to be called with certain parameters and when that happens, it will return an expected result. When writing units tests for a class that would normally use the real object, we can instead supply it with a mock object. This allows us a new level of flexibility in testing.[http://www.michaelminella.com/testing/the-concept-of-mocking.html 1]&lt;br /&gt;
&lt;br /&gt;
*Ease of modifying the mock object during separate tests to get it to get it to return a range of different data. Test can pass in valid, invalid, and extreme ranges to test how the code calling it handles such situations.[http://www.michaelminella.com/testing/the-concept-of-mocking.html 1]&lt;br /&gt;
&lt;br /&gt;
*Simulation of failures, such as the inability to connect to a database, to test the failure mode of classes.&lt;br /&gt;
&lt;br /&gt;
*Encourages better structured tests and, more importantly, improved domain code by preserving encapsulation, reducing dependencies and clarifying the interactions between classes. A running Object-Oriented program is a web of objects that collaborate by calling methods on each other. There sometimes can be many dependencies that have to be met in order to call certain objects. To make the complex dependencies be easily testable, mock objects are created in order to “mock” the stages that the object needs to be in, in order to call upon another object.&lt;br /&gt;
&lt;br /&gt;
*Often times in programming, only the changes in state of an object are tested. This would be acceptable only if there was one object. However, many real world applications contain hundreds upon hundreds of different objects. Mock objects have changed the focus of test from thinking about the changes in state of an object to thinking about its interactions with other objects.[http://msdn.microsoft.com/en-us/magazine/dd882516.aspx 2]&lt;br /&gt;
&lt;br /&gt;
==='''Different Types'''===&lt;br /&gt;
&lt;br /&gt;
====Proxy====&lt;br /&gt;
A proxy object is an object that is used to take the place of a real object. This is the original concept for all mock frameworks. In the case of mock objects, a proxy object is used to imitate the real object your code is dependent on. The proxy object is created with the mocking framework, and then set it on the object using either a setter or constructor. One has to be able to set the dependency up through an external means. This is one of the reasons Dependency Injection frameworks like [http://en.wikipedia.org/wiki/Spring_Framework Java Spring] have increase in popularity because they allow the ability to inject the proxy objects without modifying code.&lt;br /&gt;
[http://www.carlosble.com/?p=348 Proxy]&lt;br /&gt;
&lt;br /&gt;
====Class Remapping====&lt;br /&gt;
The second form of mocking is to remap the class file in the class loader. The concept is relatively new and is provided by the new java.lang.Instrument class. The basic idea is that the framework tells the class loader to remap the reference to another class file it will load which will be the mocked class. This allows one to be able to mock objects that are created by using the new operator much like other Object Oriented languages. Although this approach provides more functionality than the proxy object approach, it is much more complex and harder to write and fully understand.&lt;br /&gt;
[http://download.oracle.com/docs/cd/E13189_01/kodo/docs324/ref_guide_mapping_classmapping.html Class Mapping]&lt;br /&gt;
&lt;br /&gt;
== Examples of Mocking ==&lt;br /&gt;
&lt;br /&gt;
Lets say you have a an interface that looks like this:&lt;br /&gt;
&lt;br /&gt;
  public interface FileInterface &lt;br /&gt;
  {&lt;br /&gt;
    public void openFile(String filename) ;&lt;br /&gt;
    public void closeFile() ;&lt;br /&gt;
    public String readFile() ;    &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Then you have a class that looks like this:&lt;br /&gt;
&lt;br /&gt;
  public class FileManipulator implements FileInterface &lt;br /&gt;
  {&lt;br /&gt;
    private BufferedReader in;&lt;br /&gt;
    private boolean error = false; &lt;br /&gt;
    public void openFile(String filename) &lt;br /&gt;
    {&lt;br /&gt;
      try &lt;br /&gt;
      {&lt;br /&gt;
        in = new BufferedReader(new FileReader(filename));&lt;br /&gt;
      } catch (FileNotFoundException e) {}&lt;br /&gt;
    }&lt;br /&gt;
    public void closeFile() &lt;br /&gt;
    {&lt;br /&gt;
      try &lt;br /&gt;
      {&lt;br /&gt;
        in.close();&lt;br /&gt;
      } catch (IOException e) {}&lt;br /&gt;
    }&lt;br /&gt;
    public String readFile() &lt;br /&gt;
    {&lt;br /&gt;
      String s;&lt;br /&gt;
      try &lt;br /&gt;
      {&lt;br /&gt;
        s = in.readLine();&lt;br /&gt;
      } catch (IOException e) {}&lt;br /&gt;
    &lt;br /&gt;
     return s;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
The Mock File would look something like this:&lt;br /&gt;
&lt;br /&gt;
  public class MockFileManipulator implements FileInterface &lt;br /&gt;
  {&lt;br /&gt;
    private boolean initialized = false; &lt;br /&gt;
    private boolean error = false; &lt;br /&gt;
    private String filename;&lt;br /&gt;
    public void openFile(String filename) &lt;br /&gt;
    {&lt;br /&gt;
      if (filename == null || filename.equals(&amp;quot;&amp;quot;)) &lt;br /&gt;
      {&lt;br /&gt;
        Assert.fail(&amp;quot;Name of file is either null or blank&amp;quot;);&lt;br /&gt;
      }  &lt;br /&gt;
      this.filename = filename;&lt;br /&gt;
      initialized = true; &lt;br /&gt;
    }&lt;br /&gt;
    public void closeFile() &lt;br /&gt;
    {&lt;br /&gt;
      if (!initialized) &lt;br /&gt;
      { &lt;br /&gt;
        Assert.fail(&amp;quot;Trying to close before open&amp;quot;);&lt;br /&gt;
      }  &lt;br /&gt;
    }&lt;br /&gt;
    public String readFile() &lt;br /&gt;
    {&lt;br /&gt;
      if (!initialized) &lt;br /&gt;
      { &lt;br /&gt;
        Assert.fail(&amp;quot;Trying to read before open&amp;quot;);&lt;br /&gt;
        return null;&lt;br /&gt;
      } &lt;br /&gt;
      if (filename.equals(&amp;quot;readerror&amp;quot;)) &lt;br /&gt;
      { &lt;br /&gt;
        error = true;&lt;br /&gt;
        return &amp;quot;&amp;quot;;&lt;br /&gt;
      } &lt;br /&gt;
      return null; &lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Then when you have a test class or the class that you use the FileManipulator class, instead of:&lt;br /&gt;
&lt;br /&gt;
 FileManipulator fileChanger = new FileManipulator ();&lt;br /&gt;
 fileChanger.openFile(&amp;quot;MyTestFile.txt&amp;quot;)&lt;br /&gt;
 fileChanger.readFile();&lt;br /&gt;
 fileChanger.closeFile();&lt;br /&gt;
&lt;br /&gt;
Use the MockFileManipulator constructor to define the data object.&lt;br /&gt;
&lt;br /&gt;
 MockFileManipulator fileChanger = new MockFileManipulator ();&lt;br /&gt;
 fileChanger.openFile(&amp;quot;MyTestFile.txt&amp;quot;)&lt;br /&gt;
 fileChanger.readFile();&lt;br /&gt;
 fileChanger.closeFile();&lt;br /&gt;
&lt;br /&gt;
== Comparison of Different Systems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''EasyMock'''===&lt;br /&gt;
*EasyMock has been the first dynamic Mock Object generator, relieving users of hand-writing Mock Objects, or generating code for them.&lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Supports re-factoring-safe Mock Objects&lt;br /&gt;
*Ability to return values and exceptions.&lt;br /&gt;
*Method order checking&lt;br /&gt;
http://easymock.org/&lt;br /&gt;
&lt;br /&gt;
==='''MOQ'''===&lt;br /&gt;
*Moq is the only mocking library for .NET developed from scratch to take full advantage of .NET 3.5 and C# 3.0 features.&lt;br /&gt;
*Supports mocking interfaces as well as classes. &lt;br /&gt;
*Supports the overriding of expectations where the test can set default expectations in a fixture setup, and override as needed on certain tests&lt;br /&gt;
*Intercept and raise events on mocks&lt;br /&gt;
http://code.google.com/p/moq/.&lt;br /&gt;
&lt;br /&gt;
==='''NMock'''===&lt;br /&gt;
*NMock is a dynamic mock object library for .NET. &lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Allows expectations to be defined and fails the test if any expectations are violated&lt;br /&gt;
*Expectations are specified beforehand and verified on the fly as the code under test is being executed, rather than afterward using assertions&lt;br /&gt;
*Implementations of interfaces are generate on the fly at runtime&lt;br /&gt;
http://www.nmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Rhino Mocks'''===&lt;br /&gt;
*Only supports mocks of interfaces, delegates and classes, including those with parametrized constructors.&lt;br /&gt;
*Expectations on the called methods by using strongly typed mocks instead of strings.&lt;br /&gt;
*Recursive mocking&lt;br /&gt;
http://ayende.com/projects/rhino-mocks.aspx&lt;br /&gt;
&lt;br /&gt;
==='''jMock'''===&lt;br /&gt;
*Forces test to be explicit about the argument values that will be passed to the expected methods&lt;br /&gt;
*Ability to write custom stubs, constraints, and Invocation Matchers&lt;br /&gt;
*Works well with the auto completion and refactoring features of your IDE&lt;br /&gt;
http://www.jmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Mocha'''===&lt;br /&gt;
*Similar to jMock only for Ruby &lt;br /&gt;
*Supports testing frameworks: Test::Unit, RSpec, test/spec, expectations, Dust, MiniTest and JtestR.&lt;br /&gt;
http://mocha.rubyforge.org/&lt;br /&gt;
&lt;br /&gt;
==='''Test::MockObject'''===&lt;br /&gt;
*Similar to jMock only for Perl&lt;br /&gt;
*Simple testing techniques&lt;br /&gt;
http://search.cpan.org/dist/Test-MockObject/lib/Test/MockObject.pm&lt;br /&gt;
&lt;br /&gt;
==='''JMockit'''===&lt;br /&gt;
&lt;br /&gt;
*Simpler and more succinct APIs for writing tests with behavior verification or state verification&lt;br /&gt;
*Provides other tools for supporting the creation of large test suites&lt;br /&gt;
*Uses class remapping instead of the original proxy dependencies&lt;br /&gt;
https://jmockit.dev.java.net/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
A mock object framework can make sure that the method under test, when executed, will in fact call certain functions on the mock object  and that the method under test will react in an appropriate way to whatever the mock objects do. Most parts of a software system do not work in isolation, but collaborate with other parts to get their job done. Writing tests provides a framework to think about functionality, Mock Objects provides a framework for making assertions about those relationships and for simulating responses. Mock Objects also allows programmers to make their tests only as precise as they need to be.&lt;br /&gt;
&lt;br /&gt;
The different frameworks provide a myriad of options for software developers to produce the correct mock tests for their software. The more complex the system, the more important it is when selecting the mock framework. Support for the framework is essential as well. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
1. [http://www.sizovpoint.com/2009/03/java-mock-frameworks-comparison.html Java Mock Framework Comparisons]&lt;br /&gt;
&lt;br /&gt;
2. [http://msdn.microsoft.com/en-us/magazine/dd882516.aspx Using Mocks And Tests To Design Role-Based Objects]&lt;br /&gt;
&lt;br /&gt;
3. [http://en.wikipedia.org/wiki/Mock_object Wikipedia - Mock object]&lt;br /&gt;
&lt;br /&gt;
4. [http://javaboutique.internet.com/tutorials/mock_objects/ Java Mock Objects]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19696</id>
		<title>CSC/ECE 517 Fall 2009/wiki1a 2 sn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19696"/>
		<updated>2009-09-17T12:15:34Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: /* Definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Comparison of Mock Frameworks ==&lt;br /&gt;
&lt;br /&gt;
When performing tests, it's convenient to have the objects be in a particular configuration, so that boundary cases can be tested.  Setting up the objects can sometimes be complicated. There are different Mock Frameworks out in the development community that can be used to develop these tests. This page attempts to define and compare these different types of [http://en.wikipedia.org/wiki/Framework frameworks].&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. A computer programmer typically creates a mock object to test the behavior of some other object, in much the same way that a car designer uses a crash test dummy to simulate the dynamic behavior of a human in vehicle impacts. [http://en.wikipedia.org/wiki/Mock_object 3]&lt;br /&gt;
&lt;br /&gt;
Mock frameworks are the environments that are available to create these mock objects and mock tests. &lt;br /&gt;
There are many different types of frameworks for different platforms. They are a set of programmable [ http://en.wikipedia.org/wiki/Application_programming_interface APIs] that allow creation of mock and stub objects in relative easy fashion. Mock frameworks save the developer from the need to write repetitive code to test or simulate object interactions.&lt;br /&gt;
&lt;br /&gt;
== Concepts ==&lt;br /&gt;
&lt;br /&gt;
==='''Why Mock?'''===&lt;br /&gt;
&lt;br /&gt;
*The concept behind mock objects is that there is a need to create an object that will take the place of the real object. This mock object will expect a certain method to be called with certain parameters and when that happens, it will return an expected result. When writing units tests for a class that would normally use the real object, we can instead supply it with a mock object. This allows us a new level of flexibility in testing.[http://www.michaelminella.com/testing/the-concept-of-mocking.html 1]&lt;br /&gt;
&lt;br /&gt;
*Ease of modifying the mock object during separate tests to get it to get it to return a range of different data. Test can pass in valid, invalid, and extreme ranges to test how the code calling it handles such situations.[http://www.michaelminella.com/testing/the-concept-of-mocking.html 1]&lt;br /&gt;
&lt;br /&gt;
*Simulation of failures, such as the inability to connect to a database, to test the failure mode of classes.&lt;br /&gt;
&lt;br /&gt;
*Encourages better structured tests and, more importantly, improved domain code by preserving encapsulation, reducing dependencies and clarifying the interactions between classes. A running Object-Oriented program is a web of objects that collaborate by calling methods on each other. There sometimes can be many dependencies that have to be met in order to call certain objects. To make the complex dependencies be easily testable, mock objects are created in order to “mock” the stages that the object needs to be in, in order to call upon another object.&lt;br /&gt;
&lt;br /&gt;
*Often times in programming, only the changes in state of an object are tested. This would be acceptable only if there was one object. However, many real world applications contain hundreds upon hundreds of different objects. Mock objects have changed the focus of test from thinking about the changes in state of an object to thinking about its interactions with other objects.[http://msdn.microsoft.com/en-us/magazine/dd882516.aspx 2]&lt;br /&gt;
&lt;br /&gt;
==='''Different Types'''===&lt;br /&gt;
&lt;br /&gt;
====Proxy====&lt;br /&gt;
A proxy object is an object that is used to take the place of a real object. This is the original concept for all mock frameworks. In the case of mock objects, a proxy object is used to imitate the real object your code is dependent on. The proxy object is created with the mocking framework, and then set it on the object using either a setter or constructor. One has to be able to set the dependency up through an external means. This is one of the reasons Dependency Injection frameworks like [http://en.wikipedia.org/wiki/Spring_Framework Java Spring] have increase in popularity because they allow the ability to inject the proxy objects without modifying code.&lt;br /&gt;
[http://www.carlosble.com/?p=348 Proxy]&lt;br /&gt;
&lt;br /&gt;
====Class Remapping====&lt;br /&gt;
The second form of mocking is to remap the class file in the class loader. The concept is relatively new and is provided by the new java.lang.Instrument class. The basic idea is that the framework tells the class loader to remap the reference to another class file it will load which will be the mocked class. This allows one to be able to mock objects that are created by using the new operator much like other Object Oriented languages. Although this approach provides more functionality than the proxy object approach, it is much more complex and harder to write and fully understand.&lt;br /&gt;
[http://download.oracle.com/docs/cd/E13189_01/kodo/docs324/ref_guide_mapping_classmapping.html Class Mapping]&lt;br /&gt;
&lt;br /&gt;
== Examples of Mocking ==&lt;br /&gt;
&lt;br /&gt;
Lets say you have a an interface that looks like this:&lt;br /&gt;
&lt;br /&gt;
  public interface FileInterface &lt;br /&gt;
  {&lt;br /&gt;
    public void openFile(String filename) ;&lt;br /&gt;
    public void closeFile() ;&lt;br /&gt;
    public String readFile() ;    &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Then you have a class that looks like this:&lt;br /&gt;
&lt;br /&gt;
  public class FileManipulator implements FileInterface &lt;br /&gt;
  {&lt;br /&gt;
    private BufferedReader in;&lt;br /&gt;
    private boolean error = false; &lt;br /&gt;
    public void openFile(String filename) &lt;br /&gt;
    {&lt;br /&gt;
      try &lt;br /&gt;
      {&lt;br /&gt;
        in = new BufferedReader(new FileReader(filename));&lt;br /&gt;
      } catch (FileNotFoundException e) {}&lt;br /&gt;
    }&lt;br /&gt;
    public void closeFile() &lt;br /&gt;
    {&lt;br /&gt;
      try &lt;br /&gt;
      {&lt;br /&gt;
        in.close();&lt;br /&gt;
      } catch (IOException e) {}&lt;br /&gt;
    }&lt;br /&gt;
    public String readFile() &lt;br /&gt;
    {&lt;br /&gt;
      String s;&lt;br /&gt;
      try &lt;br /&gt;
      {&lt;br /&gt;
        s = in.readLine();&lt;br /&gt;
      } catch (IOException e) {}&lt;br /&gt;
    &lt;br /&gt;
     return s;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
The Mock File would look something like this:&lt;br /&gt;
&lt;br /&gt;
  public class MockFileManipulator implements FileInterface &lt;br /&gt;
  {&lt;br /&gt;
    private boolean initialized = false; &lt;br /&gt;
    private boolean error = false; &lt;br /&gt;
    private String filename;&lt;br /&gt;
    public void openFile(String filename) &lt;br /&gt;
    {&lt;br /&gt;
      if (filename == null || filename.equals(&amp;quot;&amp;quot;)) &lt;br /&gt;
      {&lt;br /&gt;
        Assert.fail(&amp;quot;Name of file is either null or blank&amp;quot;);&lt;br /&gt;
      }  &lt;br /&gt;
      this.filename = filename;&lt;br /&gt;
      initialized = true; &lt;br /&gt;
    }&lt;br /&gt;
    public void closeFile() &lt;br /&gt;
    {&lt;br /&gt;
      if (!initialized) &lt;br /&gt;
      { &lt;br /&gt;
        Assert.fail(&amp;quot;Trying to close before open&amp;quot;);&lt;br /&gt;
      }  &lt;br /&gt;
    }&lt;br /&gt;
    public String readFile() &lt;br /&gt;
    {&lt;br /&gt;
      if (!initialized) &lt;br /&gt;
      { &lt;br /&gt;
        Assert.fail(&amp;quot;Trying to read before open&amp;quot;);&lt;br /&gt;
        return null;&lt;br /&gt;
      } &lt;br /&gt;
      if (filename.equals(&amp;quot;readerror&amp;quot;)) &lt;br /&gt;
      { &lt;br /&gt;
        error = true;&lt;br /&gt;
        return &amp;quot;&amp;quot;;&lt;br /&gt;
      } &lt;br /&gt;
      return null; &lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Then when you have a test class or the class that you use the FileManipulator class, instead of:&lt;br /&gt;
&lt;br /&gt;
 FileManipulator fileChanger = new FileManipulator ();&lt;br /&gt;
 fileChanger.openFile(&amp;quot;MyTestFile.txt&amp;quot;)&lt;br /&gt;
 fileChanger.readFile();&lt;br /&gt;
 fileChanger.closeFile();&lt;br /&gt;
&lt;br /&gt;
Use the MockFileManipulator constructor to define the data object.&lt;br /&gt;
&lt;br /&gt;
 MockFileManipulator fileChanger = new MockFileManipulator ();&lt;br /&gt;
 fileChanger.openFile(&amp;quot;MyTestFile.txt&amp;quot;)&lt;br /&gt;
 fileChanger.readFile();&lt;br /&gt;
 fileChanger.closeFile();&lt;br /&gt;
&lt;br /&gt;
== Comparison of Different Systems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''EasyMock'''===&lt;br /&gt;
*EasyMock has been the first dynamic Mock Object generator, relieving users of hand-writing Mock Objects, or generating code for them.&lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Supports re-factoring-safe Mock Objects&lt;br /&gt;
*Ability to return values and exceptions.&lt;br /&gt;
*Method order checking&lt;br /&gt;
http://easymock.org/&lt;br /&gt;
&lt;br /&gt;
==='''MOQ'''===&lt;br /&gt;
*Moq is the only mocking library for .NET developed from scratch to take full advantage of .NET 3.5 and C# 3.0 features.&lt;br /&gt;
*Supports mocking interfaces as well as classes. &lt;br /&gt;
*Supports the overriding of expectations where the test can set default expectations in a fixture setup, and override as needed on certain tests&lt;br /&gt;
*Intercept and raise events on mocks&lt;br /&gt;
http://code.google.com/p/moq/.&lt;br /&gt;
&lt;br /&gt;
==='''NMock'''===&lt;br /&gt;
*NMock is a dynamic mock object library for .NET. &lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Allows expectations to be defined and fails the test if any expectations are violated&lt;br /&gt;
*Expectations are specified beforehand and verified on the fly as the code under test is being executed, rather than afterward using assertions&lt;br /&gt;
*Implementations of interfaces are generate on the fly at runtime&lt;br /&gt;
http://www.nmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Rhino Mocks'''===&lt;br /&gt;
*Only supports mocks of interfaces, delegates and classes, including those with parametrized constructors.&lt;br /&gt;
*Expectations on the called methods by using strongly typed mocks instead of strings.&lt;br /&gt;
*Recursive mocking&lt;br /&gt;
http://ayende.com/projects/rhino-mocks.aspx&lt;br /&gt;
&lt;br /&gt;
==='''jMock'''===&lt;br /&gt;
*Forces test to be explicit about the argument values that will be passed to the expected methods&lt;br /&gt;
*Ability to write custom stubs, constraints, and Invocation Matchers&lt;br /&gt;
*Works well with the auto completion and refactoring features of your IDE&lt;br /&gt;
http://www.jmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Mocha'''===&lt;br /&gt;
*Similar to jMock only for Ruby &lt;br /&gt;
*Supports testing frameworks: Test::Unit, RSpec, test/spec, expectations, Dust, MiniTest and JtestR.&lt;br /&gt;
http://mocha.rubyforge.org/&lt;br /&gt;
&lt;br /&gt;
==='''Test::MockObject'''===&lt;br /&gt;
*Similar to jMock only for Perl&lt;br /&gt;
*Simple testing techniques&lt;br /&gt;
http://search.cpan.org/dist/Test-MockObject/lib/Test/MockObject.pm&lt;br /&gt;
&lt;br /&gt;
==='''JMockit'''===&lt;br /&gt;
&lt;br /&gt;
*Simpler and more succinct APIs for writing tests with behavior verification or state verification&lt;br /&gt;
*Provides other tools for supporting the creation of large test suites&lt;br /&gt;
*Uses class remapping instead of the original proxy dependencies&lt;br /&gt;
https://jmockit.dev.java.net/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
A mock object framework can make sure that the method under test, when executed, will in fact call certain functions on the mock object  and that the method under test will react in an appropriate way to whatever the mock objects do. Most parts of a software system do not work in isolation, but collaborate with other parts to get their job done. Writing tests provides a framework to think about functionality, Mock Objects provides a framework for making assertions about those relationships and for simulating responses. Mock Objects also allows programmers to make their tests only as precise as they need to be.&lt;br /&gt;
&lt;br /&gt;
The different frameworks provide a myriad of options for software developers to produce the correct mock tests for their software. The more complex the system, the more important it is when selecting the mock framework. Support for the framework is essential as well. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
1. [http://www.sizovpoint.com/2009/03/java-mock-frameworks-comparison.html Java Mock Framework Comparisons]&lt;br /&gt;
&lt;br /&gt;
2. [http://msdn.microsoft.com/en-us/magazine/dd882516.aspx Using Mocks And Tests To Design Role-Based Objects]&lt;br /&gt;
&lt;br /&gt;
3. [http://en.wikipedia.org/wiki/Mock_object Wikipedia - Mock object]&lt;br /&gt;
&lt;br /&gt;
4. [http://javaboutique.internet.com/tutorials/mock_objects/ Java Mock Objects]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19694</id>
		<title>CSC/ECE 517 Fall 2009/wiki1a 2 sn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19694"/>
		<updated>2009-09-17T12:14:56Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: /* Comparison of Mock Frameworks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Comparison of Mock Frameworks ==&lt;br /&gt;
&lt;br /&gt;
When performing tests, it's convenient to have the objects be in a particular configuration, so that boundary cases can be tested.  Setting up the objects can sometimes be complicated. There are different Mock Frameworks out in the development community that can be used to develop these tests. This page attempts to define and compare these different types of [http://en.wikipedia.org/wiki/Framework frameworks].&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. A computer programmer typically creates a mock object to test the behavior of some other object, in much the same way that a car designer uses a crash test dummy to simulate the dynamic behavior of a human in vehicle impacts. [http://en.wikipedia.org/wiki/Mock_object 3]&lt;br /&gt;
&lt;br /&gt;
Mock frameworks are the environments that are available to create these mock objects and mock tests. &lt;br /&gt;
There are many different types of frameworks for different platforms. They are a set of programmable APIs that allow creation of mock and stub objects in relative easy fashion. Mock frameworks save the developer from the need to write repetitive code to test or simulate object interactions.&lt;br /&gt;
&lt;br /&gt;
== Concepts ==&lt;br /&gt;
&lt;br /&gt;
==='''Why Mock?'''===&lt;br /&gt;
&lt;br /&gt;
*The concept behind mock objects is that there is a need to create an object that will take the place of the real object. This mock object will expect a certain method to be called with certain parameters and when that happens, it will return an expected result. When writing units tests for a class that would normally use the real object, we can instead supply it with a mock object. This allows us a new level of flexibility in testing.[http://www.michaelminella.com/testing/the-concept-of-mocking.html 1]&lt;br /&gt;
&lt;br /&gt;
*Ease of modifying the mock object during separate tests to get it to get it to return a range of different data. Test can pass in valid, invalid, and extreme ranges to test how the code calling it handles such situations.[http://www.michaelminella.com/testing/the-concept-of-mocking.html 1]&lt;br /&gt;
&lt;br /&gt;
*Simulation of failures, such as the inability to connect to a database, to test the failure mode of classes.&lt;br /&gt;
&lt;br /&gt;
*Encourages better structured tests and, more importantly, improved domain code by preserving encapsulation, reducing dependencies and clarifying the interactions between classes. A running Object-Oriented program is a web of objects that collaborate by calling methods on each other. There sometimes can be many dependencies that have to be met in order to call certain objects. To make the complex dependencies be easily testable, mock objects are created in order to “mock” the stages that the object needs to be in, in order to call upon another object.&lt;br /&gt;
&lt;br /&gt;
*Often times in programming, only the changes in state of an object are tested. This would be acceptable only if there was one object. However, many real world applications contain hundreds upon hundreds of different objects. Mock objects have changed the focus of test from thinking about the changes in state of an object to thinking about its interactions with other objects.[http://msdn.microsoft.com/en-us/magazine/dd882516.aspx 2]&lt;br /&gt;
&lt;br /&gt;
==='''Different Types'''===&lt;br /&gt;
&lt;br /&gt;
====Proxy====&lt;br /&gt;
A proxy object is an object that is used to take the place of a real object. This is the original concept for all mock frameworks. In the case of mock objects, a proxy object is used to imitate the real object your code is dependent on. The proxy object is created with the mocking framework, and then set it on the object using either a setter or constructor. One has to be able to set the dependency up through an external means. This is one of the reasons Dependency Injection frameworks like [http://en.wikipedia.org/wiki/Spring_Framework Java Spring] have increase in popularity because they allow the ability to inject the proxy objects without modifying code.&lt;br /&gt;
[http://www.carlosble.com/?p=348 Proxy]&lt;br /&gt;
&lt;br /&gt;
====Class Remapping====&lt;br /&gt;
The second form of mocking is to remap the class file in the class loader. The concept is relatively new and is provided by the new java.lang.Instrument class. The basic idea is that the framework tells the class loader to remap the reference to another class file it will load which will be the mocked class. This allows one to be able to mock objects that are created by using the new operator much like other Object Oriented languages. Although this approach provides more functionality than the proxy object approach, it is much more complex and harder to write and fully understand.&lt;br /&gt;
[http://download.oracle.com/docs/cd/E13189_01/kodo/docs324/ref_guide_mapping_classmapping.html Class Mapping]&lt;br /&gt;
&lt;br /&gt;
== Examples of Mocking ==&lt;br /&gt;
&lt;br /&gt;
Lets say you have a an interface that looks like this:&lt;br /&gt;
&lt;br /&gt;
  public interface FileInterface &lt;br /&gt;
  {&lt;br /&gt;
    public void openFile(String filename) ;&lt;br /&gt;
    public void closeFile() ;&lt;br /&gt;
    public String readFile() ;    &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Then you have a class that looks like this:&lt;br /&gt;
&lt;br /&gt;
  public class FileManipulator implements FileInterface &lt;br /&gt;
  {&lt;br /&gt;
    private BufferedReader in;&lt;br /&gt;
    private boolean error = false; &lt;br /&gt;
    public void openFile(String filename) &lt;br /&gt;
    {&lt;br /&gt;
      try &lt;br /&gt;
      {&lt;br /&gt;
        in = new BufferedReader(new FileReader(filename));&lt;br /&gt;
      } catch (FileNotFoundException e) {}&lt;br /&gt;
    }&lt;br /&gt;
    public void closeFile() &lt;br /&gt;
    {&lt;br /&gt;
      try &lt;br /&gt;
      {&lt;br /&gt;
        in.close();&lt;br /&gt;
      } catch (IOException e) {}&lt;br /&gt;
    }&lt;br /&gt;
    public String readFile() &lt;br /&gt;
    {&lt;br /&gt;
      String s;&lt;br /&gt;
      try &lt;br /&gt;
      {&lt;br /&gt;
        s = in.readLine();&lt;br /&gt;
      } catch (IOException e) {}&lt;br /&gt;
    &lt;br /&gt;
     return s;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
The Mock File would look something like this:&lt;br /&gt;
&lt;br /&gt;
  public class MockFileManipulator implements FileInterface &lt;br /&gt;
  {&lt;br /&gt;
    private boolean initialized = false; &lt;br /&gt;
    private boolean error = false; &lt;br /&gt;
    private String filename;&lt;br /&gt;
    public void openFile(String filename) &lt;br /&gt;
    {&lt;br /&gt;
      if (filename == null || filename.equals(&amp;quot;&amp;quot;)) &lt;br /&gt;
      {&lt;br /&gt;
        Assert.fail(&amp;quot;Name of file is either null or blank&amp;quot;);&lt;br /&gt;
      }  &lt;br /&gt;
      this.filename = filename;&lt;br /&gt;
      initialized = true; &lt;br /&gt;
    }&lt;br /&gt;
    public void closeFile() &lt;br /&gt;
    {&lt;br /&gt;
      if (!initialized) &lt;br /&gt;
      { &lt;br /&gt;
        Assert.fail(&amp;quot;Trying to close before open&amp;quot;);&lt;br /&gt;
      }  &lt;br /&gt;
    }&lt;br /&gt;
    public String readFile() &lt;br /&gt;
    {&lt;br /&gt;
      if (!initialized) &lt;br /&gt;
      { &lt;br /&gt;
        Assert.fail(&amp;quot;Trying to read before open&amp;quot;);&lt;br /&gt;
        return null;&lt;br /&gt;
      } &lt;br /&gt;
      if (filename.equals(&amp;quot;readerror&amp;quot;)) &lt;br /&gt;
      { &lt;br /&gt;
        error = true;&lt;br /&gt;
        return &amp;quot;&amp;quot;;&lt;br /&gt;
      } &lt;br /&gt;
      return null; &lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Then when you have a test class or the class that you use the FileManipulator class, instead of:&lt;br /&gt;
&lt;br /&gt;
 FileManipulator fileChanger = new FileManipulator ();&lt;br /&gt;
 fileChanger.openFile(&amp;quot;MyTestFile.txt&amp;quot;)&lt;br /&gt;
 fileChanger.readFile();&lt;br /&gt;
 fileChanger.closeFile();&lt;br /&gt;
&lt;br /&gt;
Use the MockFileManipulator constructor to define the data object.&lt;br /&gt;
&lt;br /&gt;
 MockFileManipulator fileChanger = new MockFileManipulator ();&lt;br /&gt;
 fileChanger.openFile(&amp;quot;MyTestFile.txt&amp;quot;)&lt;br /&gt;
 fileChanger.readFile();&lt;br /&gt;
 fileChanger.closeFile();&lt;br /&gt;
&lt;br /&gt;
== Comparison of Different Systems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''EasyMock'''===&lt;br /&gt;
*EasyMock has been the first dynamic Mock Object generator, relieving users of hand-writing Mock Objects, or generating code for them.&lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Supports re-factoring-safe Mock Objects&lt;br /&gt;
*Ability to return values and exceptions.&lt;br /&gt;
*Method order checking&lt;br /&gt;
http://easymock.org/&lt;br /&gt;
&lt;br /&gt;
==='''MOQ'''===&lt;br /&gt;
*Moq is the only mocking library for .NET developed from scratch to take full advantage of .NET 3.5 and C# 3.0 features.&lt;br /&gt;
*Supports mocking interfaces as well as classes. &lt;br /&gt;
*Supports the overriding of expectations where the test can set default expectations in a fixture setup, and override as needed on certain tests&lt;br /&gt;
*Intercept and raise events on mocks&lt;br /&gt;
http://code.google.com/p/moq/.&lt;br /&gt;
&lt;br /&gt;
==='''NMock'''===&lt;br /&gt;
*NMock is a dynamic mock object library for .NET. &lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Allows expectations to be defined and fails the test if any expectations are violated&lt;br /&gt;
*Expectations are specified beforehand and verified on the fly as the code under test is being executed, rather than afterward using assertions&lt;br /&gt;
*Implementations of interfaces are generate on the fly at runtime&lt;br /&gt;
http://www.nmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Rhino Mocks'''===&lt;br /&gt;
*Only supports mocks of interfaces, delegates and classes, including those with parametrized constructors.&lt;br /&gt;
*Expectations on the called methods by using strongly typed mocks instead of strings.&lt;br /&gt;
*Recursive mocking&lt;br /&gt;
http://ayende.com/projects/rhino-mocks.aspx&lt;br /&gt;
&lt;br /&gt;
==='''jMock'''===&lt;br /&gt;
*Forces test to be explicit about the argument values that will be passed to the expected methods&lt;br /&gt;
*Ability to write custom stubs, constraints, and Invocation Matchers&lt;br /&gt;
*Works well with the auto completion and refactoring features of your IDE&lt;br /&gt;
http://www.jmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Mocha'''===&lt;br /&gt;
*Similar to jMock only for Ruby &lt;br /&gt;
*Supports testing frameworks: Test::Unit, RSpec, test/spec, expectations, Dust, MiniTest and JtestR.&lt;br /&gt;
http://mocha.rubyforge.org/&lt;br /&gt;
&lt;br /&gt;
==='''Test::MockObject'''===&lt;br /&gt;
*Similar to jMock only for Perl&lt;br /&gt;
*Simple testing techniques&lt;br /&gt;
http://search.cpan.org/dist/Test-MockObject/lib/Test/MockObject.pm&lt;br /&gt;
&lt;br /&gt;
==='''JMockit'''===&lt;br /&gt;
&lt;br /&gt;
*Simpler and more succinct APIs for writing tests with behavior verification or state verification&lt;br /&gt;
*Provides other tools for supporting the creation of large test suites&lt;br /&gt;
*Uses class remapping instead of the original proxy dependencies&lt;br /&gt;
https://jmockit.dev.java.net/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
A mock object framework can make sure that the method under test, when executed, will in fact call certain functions on the mock object  and that the method under test will react in an appropriate way to whatever the mock objects do. Most parts of a software system do not work in isolation, but collaborate with other parts to get their job done. Writing tests provides a framework to think about functionality, Mock Objects provides a framework for making assertions about those relationships and for simulating responses. Mock Objects also allows programmers to make their tests only as precise as they need to be.&lt;br /&gt;
&lt;br /&gt;
The different frameworks provide a myriad of options for software developers to produce the correct mock tests for their software. The more complex the system, the more important it is when selecting the mock framework. Support for the framework is essential as well. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
1. [http://www.sizovpoint.com/2009/03/java-mock-frameworks-comparison.html Java Mock Framework Comparisons]&lt;br /&gt;
&lt;br /&gt;
2. [http://msdn.microsoft.com/en-us/magazine/dd882516.aspx Using Mocks And Tests To Design Role-Based Objects]&lt;br /&gt;
&lt;br /&gt;
3. [http://en.wikipedia.org/wiki/Mock_object Wikipedia - Mock object]&lt;br /&gt;
&lt;br /&gt;
4. [http://javaboutique.internet.com/tutorials/mock_objects/ Java Mock Objects]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19690</id>
		<title>CSC/ECE 517 Fall 2009/wiki1a 2 sn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19690"/>
		<updated>2009-09-17T12:10:31Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: /* Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Comparison of Mock Frameworks ==&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. A computer programmer typically creates a mock object to test the behavior of some other object, in much the same way that a car designer uses a crash test dummy to simulate the dynamic behavior of a human in vehicle impacts. [http://en.wikipedia.org/wiki/Mock_object 3]&lt;br /&gt;
&lt;br /&gt;
Mock frameworks are the environments that are available to create these mock objects and mock tests. &lt;br /&gt;
There are many different types of frameworks for different platforms. They are a set of programmable APIs that allow creation of mock and stub objects in relative easy fashion. Mock frameworks save the developer from the need to write repetitive code to test or simulate object interactions.&lt;br /&gt;
&lt;br /&gt;
== Concepts ==&lt;br /&gt;
&lt;br /&gt;
==='''Why Mock?'''===&lt;br /&gt;
&lt;br /&gt;
*The concept behind mock objects is that there is a need to create an object that will take the place of the real object. This mock object will expect a certain method to be called with certain parameters and when that happens, it will return an expected result. When writing units tests for a class that would normally use the real object, we can instead supply it with a mock object. This allows us a new level of flexibility in testing.[http://www.michaelminella.com/testing/the-concept-of-mocking.html 1]&lt;br /&gt;
&lt;br /&gt;
*Ease of modifying the mock object during separate tests to get it to get it to return a range of different data. Test can pass in valid, invalid, and extreme ranges to test how the code calling it handles such situations.[http://www.michaelminella.com/testing/the-concept-of-mocking.html 1]&lt;br /&gt;
&lt;br /&gt;
*Simulation of failures, such as the inability to connect to a database, to test the failure mode of classes.&lt;br /&gt;
&lt;br /&gt;
*Encourages better structured tests and, more importantly, improved domain code by preserving encapsulation, reducing dependencies and clarifying the interactions between classes. A running Object-Oriented program is a web of objects that collaborate by calling methods on each other. There sometimes can be many dependencies that have to be met in order to call certain objects. To make the complex dependencies be easily testable, mock objects are created in order to “mock” the stages that the object needs to be in, in order to call upon another object.&lt;br /&gt;
&lt;br /&gt;
*Often times in programming, only the changes in state of an object are tested. This would be acceptable only if there was one object. However, many real world applications contain hundreds upon hundreds of different objects. Mock objects have changed the focus of test from thinking about the changes in state of an object to thinking about its interactions with other objects.[http://msdn.microsoft.com/en-us/magazine/dd882516.aspx 2]&lt;br /&gt;
&lt;br /&gt;
==='''Different Types'''===&lt;br /&gt;
&lt;br /&gt;
====Proxy====&lt;br /&gt;
A proxy object is an object that is used to take the place of a real object. This is the original concept for all mock frameworks. In the case of mock objects, a proxy object is used to imitate the real object your code is dependent on. The proxy object is created with the mocking framework, and then set it on the object using either a setter or constructor. One has to be able to set the dependency up through an external means. This is one of the reasons Dependency Injection frameworks like [http://en.wikipedia.org/wiki/Spring_Framework Java Spring] have increase in popularity because they allow the ability to inject the proxy objects without modifying code.&lt;br /&gt;
[http://www.carlosble.com/?p=348 Proxy]&lt;br /&gt;
&lt;br /&gt;
====Class Remapping====&lt;br /&gt;
The second form of mocking is to remap the class file in the class loader. The concept is relatively new and is provided by the new java.lang.Instrument class. The basic idea is that the framework tells the class loader to remap the reference to another class file it will load which will be the mocked class. This allows one to be able to mock objects that are created by using the new operator much like other Object Oriented languages. Although this approach provides more functionality than the proxy object approach, it is much more complex and harder to write and fully understand.&lt;br /&gt;
[http://download.oracle.com/docs/cd/E13189_01/kodo/docs324/ref_guide_mapping_classmapping.html Class Mapping]&lt;br /&gt;
&lt;br /&gt;
== Examples of Mocking ==&lt;br /&gt;
&lt;br /&gt;
Lets say you have a an interface that looks like this:&lt;br /&gt;
&lt;br /&gt;
  public interface FileInterface &lt;br /&gt;
  {&lt;br /&gt;
    public void openFile(String filename) ;&lt;br /&gt;
    public void closeFile() ;&lt;br /&gt;
    public String readFile() ;    &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Then you have a class that looks like this:&lt;br /&gt;
&lt;br /&gt;
  public class FileManipulator implements FileInterface &lt;br /&gt;
  {&lt;br /&gt;
    private BufferedReader in;&lt;br /&gt;
    private boolean error = false; &lt;br /&gt;
    public void openFile(String filename) &lt;br /&gt;
    {&lt;br /&gt;
      try &lt;br /&gt;
      {&lt;br /&gt;
        in = new BufferedReader(new FileReader(filename));&lt;br /&gt;
      } catch (FileNotFoundException e) {}&lt;br /&gt;
    }&lt;br /&gt;
    public void closeFile() &lt;br /&gt;
    {&lt;br /&gt;
      try &lt;br /&gt;
      {&lt;br /&gt;
        in.close();&lt;br /&gt;
      } catch (IOException e) {}&lt;br /&gt;
    }&lt;br /&gt;
    public String readFile() &lt;br /&gt;
    {&lt;br /&gt;
      String s;&lt;br /&gt;
      try &lt;br /&gt;
      {&lt;br /&gt;
        s = in.readLine();&lt;br /&gt;
      } catch (IOException e) {}&lt;br /&gt;
    &lt;br /&gt;
     return s;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
The Mock File would look something like this:&lt;br /&gt;
&lt;br /&gt;
  public class MockFileManipulator implements FileInterface &lt;br /&gt;
  {&lt;br /&gt;
    private boolean initialized = false; &lt;br /&gt;
    private boolean error = false; &lt;br /&gt;
    private String filename;&lt;br /&gt;
    public void openFile(String filename) &lt;br /&gt;
    {&lt;br /&gt;
      if (filename == null || filename.equals(&amp;quot;&amp;quot;)) &lt;br /&gt;
      {&lt;br /&gt;
        Assert.fail(&amp;quot;Name of file is either null or blank&amp;quot;);&lt;br /&gt;
      }  &lt;br /&gt;
      this.filename = filename;&lt;br /&gt;
      initialized = true; &lt;br /&gt;
    }&lt;br /&gt;
    public void closeFile() &lt;br /&gt;
    {&lt;br /&gt;
      if (!initialized) &lt;br /&gt;
      { &lt;br /&gt;
        Assert.fail(&amp;quot;Trying to close before open&amp;quot;);&lt;br /&gt;
      }  &lt;br /&gt;
    }&lt;br /&gt;
    public String readFile() &lt;br /&gt;
    {&lt;br /&gt;
      if (!initialized) &lt;br /&gt;
      { &lt;br /&gt;
        Assert.fail(&amp;quot;Trying to read before open&amp;quot;);&lt;br /&gt;
        return null;&lt;br /&gt;
      } &lt;br /&gt;
      if (filename.equals(&amp;quot;readerror&amp;quot;)) &lt;br /&gt;
      { &lt;br /&gt;
        error = true;&lt;br /&gt;
        return &amp;quot;&amp;quot;;&lt;br /&gt;
      } &lt;br /&gt;
      return null; &lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Then when you have a test class or the class that you use the FileManipulator class, instead of:&lt;br /&gt;
&lt;br /&gt;
 FileManipulator fileChanger = new FileManipulator ();&lt;br /&gt;
 fileChanger.openFile(&amp;quot;MyTestFile.txt&amp;quot;)&lt;br /&gt;
 fileChanger.readFile();&lt;br /&gt;
 fileChanger.closeFile();&lt;br /&gt;
&lt;br /&gt;
Use the MockFileManipulator constructor to define the data object.&lt;br /&gt;
&lt;br /&gt;
 MockFileManipulator fileChanger = new MockFileManipulator ();&lt;br /&gt;
 fileChanger.openFile(&amp;quot;MyTestFile.txt&amp;quot;)&lt;br /&gt;
 fileChanger.readFile();&lt;br /&gt;
 fileChanger.closeFile();&lt;br /&gt;
&lt;br /&gt;
== Comparison of Different Systems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''EasyMock'''===&lt;br /&gt;
*EasyMock has been the first dynamic Mock Object generator, relieving users of hand-writing Mock Objects, or generating code for them.&lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Supports re-factoring-safe Mock Objects&lt;br /&gt;
*Ability to return values and exceptions.&lt;br /&gt;
*Method order checking&lt;br /&gt;
http://easymock.org/&lt;br /&gt;
&lt;br /&gt;
==='''MOQ'''===&lt;br /&gt;
*Moq is the only mocking library for .NET developed from scratch to take full advantage of .NET 3.5 and C# 3.0 features.&lt;br /&gt;
*Supports mocking interfaces as well as classes. &lt;br /&gt;
*Supports the overriding of expectations where the test can set default expectations in a fixture setup, and override as needed on certain tests&lt;br /&gt;
*Intercept and raise events on mocks&lt;br /&gt;
http://code.google.com/p/moq/.&lt;br /&gt;
&lt;br /&gt;
==='''NMock'''===&lt;br /&gt;
*NMock is a dynamic mock object library for .NET. &lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Allows expectations to be defined and fails the test if any expectations are violated&lt;br /&gt;
*Expectations are specified beforehand and verified on the fly as the code under test is being executed, rather than afterward using assertions&lt;br /&gt;
*Implementations of interfaces are generate on the fly at runtime&lt;br /&gt;
http://www.nmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Rhino Mocks'''===&lt;br /&gt;
*Only supports mocks of interfaces, delegates and classes, including those with parametrized constructors.&lt;br /&gt;
*Expectations on the called methods by using strongly typed mocks instead of strings.&lt;br /&gt;
*Recursive mocking&lt;br /&gt;
http://ayende.com/projects/rhino-mocks.aspx&lt;br /&gt;
&lt;br /&gt;
==='''jMock'''===&lt;br /&gt;
*Forces test to be explicit about the argument values that will be passed to the expected methods&lt;br /&gt;
*Ability to write custom stubs, constraints, and Invocation Matchers&lt;br /&gt;
*Works well with the auto completion and refactoring features of your IDE&lt;br /&gt;
http://www.jmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Mocha'''===&lt;br /&gt;
*Similar to jMock only for Ruby &lt;br /&gt;
*Supports testing frameworks: Test::Unit, RSpec, test/spec, expectations, Dust, MiniTest and JtestR.&lt;br /&gt;
http://mocha.rubyforge.org/&lt;br /&gt;
&lt;br /&gt;
==='''Test::MockObject'''===&lt;br /&gt;
*Similar to jMock only for Perl&lt;br /&gt;
*Simple testing techniques&lt;br /&gt;
http://search.cpan.org/dist/Test-MockObject/lib/Test/MockObject.pm&lt;br /&gt;
&lt;br /&gt;
==='''JMockit'''===&lt;br /&gt;
&lt;br /&gt;
*Simpler and more succinct APIs for writing tests with behavior verification or state verification&lt;br /&gt;
*Provides other tools for supporting the creation of large test suites&lt;br /&gt;
*Uses class remapping instead of the original proxy dependencies&lt;br /&gt;
https://jmockit.dev.java.net/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
A mock object framework can make sure that the method under test, when executed, will in fact call certain functions on the mock object  and that the method under test will react in an appropriate way to whatever the mock objects do. Most parts of a software system do not work in isolation, but collaborate with other parts to get their job done. Writing tests provides a framework to think about functionality, Mock Objects provides a framework for making assertions about those relationships and for simulating responses. Mock Objects also allows programmers to make their tests only as precise as they need to be.&lt;br /&gt;
&lt;br /&gt;
The different frameworks provide a myriad of options for software developers to produce the correct mock tests for their software. The more complex the system, the more important it is when selecting the mock framework. Support for the framework is essential as well. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
1. [http://www.sizovpoint.com/2009/03/java-mock-frameworks-comparison.html Java Mock Framework Comparisons]&lt;br /&gt;
&lt;br /&gt;
2. [http://msdn.microsoft.com/en-us/magazine/dd882516.aspx Using Mocks And Tests To Design Role-Based Objects]&lt;br /&gt;
&lt;br /&gt;
3. [http://en.wikipedia.org/wiki/Mock_object Wikipedia - Mock object]&lt;br /&gt;
&lt;br /&gt;
4. [http://javaboutique.internet.com/tutorials/mock_objects/ Java Mock Objects]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19688</id>
		<title>CSC/ECE 517 Fall 2009/wiki1a 2 sn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19688"/>
		<updated>2009-09-17T12:09:42Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: /* Examples of Mocking */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Comparison of Mock Frameworks ==&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. A computer programmer typically creates a mock object to test the behavior of some other object, in much the same way that a car designer uses a crash test dummy to simulate the dynamic behavior of a human in vehicle impacts. [http://en.wikipedia.org/wiki/Mock_object 3]&lt;br /&gt;
&lt;br /&gt;
Mock frameworks are the environments that are available to create these mock objects and mock tests. &lt;br /&gt;
There are many different types of frameworks for different platforms. They are a set of programmable APIs that allow creation of mock and stub objects in relative easy fashion. Mock frameworks save the developer from the need to write repetitive code to test or simulate object interactions.&lt;br /&gt;
&lt;br /&gt;
== Concepts ==&lt;br /&gt;
&lt;br /&gt;
==='''Why Mock?'''===&lt;br /&gt;
&lt;br /&gt;
*The concept behind mock objects is that there is a need to create an object that will take the place of the real object. This mock object will expect a certain method to be called with certain parameters and when that happens, it will return an expected result. When writing units tests for a class that would normally use the real object, we can instead supply it with a mock object. This allows us a new level of flexibility in testing.[http://www.michaelminella.com/testing/the-concept-of-mocking.html 1]&lt;br /&gt;
&lt;br /&gt;
*Ease of modifying the mock object during separate tests to get it to get it to return a range of different data. Test can pass in valid, invalid, and extreme ranges to test how the code calling it handles such situations.[http://www.michaelminella.com/testing/the-concept-of-mocking.html 1]&lt;br /&gt;
&lt;br /&gt;
*Simulation of failures, such as the inability to connect to a database, to test the failure mode of classes.&lt;br /&gt;
&lt;br /&gt;
*Encourages better structured tests and, more importantly, improved domain code by preserving encapsulation, reducing dependencies and clarifying the interactions between classes. A running Object-Oriented program is a web of objects that collaborate by calling methods on each other. There sometimes can be many dependencies that have to be met in order to call certain objects. To make the complex dependencies be easily testable, mock objects are created in order to “mock” the stages that the object needs to be in, in order to call upon another object.&lt;br /&gt;
&lt;br /&gt;
*Often times in programming, only the changes in state of an object are tested. This would be acceptable only if there was one object. However, many real world applications contain hundreds upon hundreds of different objects. Mock objects have changed the focus of test from thinking about the changes in state of an object to thinking about its interactions with other objects.[http://msdn.microsoft.com/en-us/magazine/dd882516.aspx 2]&lt;br /&gt;
&lt;br /&gt;
==='''Different Types'''===&lt;br /&gt;
&lt;br /&gt;
====Proxy====&lt;br /&gt;
A proxy object is an object that is used to take the place of a real object. This is the original concept for all mock frameworks. In the case of mock objects, a proxy object is used to imitate the real object your code is dependent on. The proxy object is created with the mocking framework, and then set it on the object using either a setter or constructor. One has to be able to set the dependency up through an external means. This is one of the reasons Dependency Injection frameworks like [http://en.wikipedia.org/wiki/Spring_Framework Java Spring] have increase in popularity because they allow the ability to inject the proxy objects without modifying code.&lt;br /&gt;
[http://www.carlosble.com/?p=348 Proxy]&lt;br /&gt;
&lt;br /&gt;
====Class Remapping====&lt;br /&gt;
The second form of mocking is to remap the class file in the class loader. The concept is relatively new and is provided by the new java.lang.Instrument class. The basic idea is that the framework tells the class loader to remap the reference to another class file it will load which will be the mocked class. This allows one to be able to mock objects that are created by using the new operator much like other Object Oriented languages. Although this approach provides more functionality than the proxy object approach, it is much more complex and harder to write and fully understand.&lt;br /&gt;
[http://download.oracle.com/docs/cd/E13189_01/kodo/docs324/ref_guide_mapping_classmapping.html Class Mapping]&lt;br /&gt;
&lt;br /&gt;
== Examples of Mocking ==&lt;br /&gt;
&lt;br /&gt;
Lets say you have a an interface that looks like this:&lt;br /&gt;
&lt;br /&gt;
  public interface FileInterface &lt;br /&gt;
  {&lt;br /&gt;
    public void openFile(String filename) ;&lt;br /&gt;
    public void closeFile() ;&lt;br /&gt;
    public String readFile() ;    &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Then you have a class that looks like this:&lt;br /&gt;
&lt;br /&gt;
  public class FileManipulator implements FileInterface &lt;br /&gt;
  {&lt;br /&gt;
    private BufferedReader in;&lt;br /&gt;
    private boolean error = false; &lt;br /&gt;
    public void openFile(String filename) &lt;br /&gt;
    {&lt;br /&gt;
      try &lt;br /&gt;
      {&lt;br /&gt;
        in = new BufferedReader(new FileReader(filename));&lt;br /&gt;
      } catch (FileNotFoundException e) {}&lt;br /&gt;
    }&lt;br /&gt;
    public void closeFile() &lt;br /&gt;
    {&lt;br /&gt;
      try &lt;br /&gt;
      {&lt;br /&gt;
        in.close();&lt;br /&gt;
      } catch (IOException e) {}&lt;br /&gt;
    }&lt;br /&gt;
    public String readFile() &lt;br /&gt;
    {&lt;br /&gt;
      String s;&lt;br /&gt;
      try &lt;br /&gt;
      {&lt;br /&gt;
        s = in.readLine();&lt;br /&gt;
      } catch (IOException e) {}&lt;br /&gt;
    &lt;br /&gt;
     return s;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
The Mock File would look something like this:&lt;br /&gt;
&lt;br /&gt;
  public class MockFileManipulator implements FileInterface &lt;br /&gt;
  {&lt;br /&gt;
    private boolean initialized = false; &lt;br /&gt;
    private boolean error = false; &lt;br /&gt;
    private String filename;&lt;br /&gt;
    public void openFile(String filename) &lt;br /&gt;
    {&lt;br /&gt;
      if (filename == null || filename.equals(&amp;quot;&amp;quot;)) &lt;br /&gt;
      {&lt;br /&gt;
        Assert.fail(&amp;quot;Name of file is either null or blank&amp;quot;);&lt;br /&gt;
      }  &lt;br /&gt;
      this.filename = filename;&lt;br /&gt;
      initialized = true; &lt;br /&gt;
    }&lt;br /&gt;
    public void closeFile() &lt;br /&gt;
    {&lt;br /&gt;
      if (!initialized) &lt;br /&gt;
      { &lt;br /&gt;
        Assert.fail(&amp;quot;Trying to close before open&amp;quot;);&lt;br /&gt;
      }  &lt;br /&gt;
    }&lt;br /&gt;
    public String readFile() &lt;br /&gt;
    {&lt;br /&gt;
      if (!initialized) &lt;br /&gt;
      { &lt;br /&gt;
        Assert.fail(&amp;quot;Trying to read before open&amp;quot;);&lt;br /&gt;
        return null;&lt;br /&gt;
      } &lt;br /&gt;
      if (filename.equals(&amp;quot;readerror&amp;quot;)) &lt;br /&gt;
      { &lt;br /&gt;
        error = true;&lt;br /&gt;
        return &amp;quot;&amp;quot;;&lt;br /&gt;
      } &lt;br /&gt;
      return null; &lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Then when you have a test class or the class that you use the FileManipulator class, instead of:&lt;br /&gt;
&lt;br /&gt;
 FileManipulator fileChanger = new FileManipulator ();&lt;br /&gt;
 fileChanger.openFile(&amp;quot;MyTestFile.txt&amp;quot;)&lt;br /&gt;
 fileChanger.readFile();&lt;br /&gt;
 fileChanger.closeFile();&lt;br /&gt;
&lt;br /&gt;
Use the MockFileManipulator constructor to define the data object.&lt;br /&gt;
&lt;br /&gt;
 MockFileManipulator fileChanger = new MockFileManipulator ();&lt;br /&gt;
 fileChanger.openFile(&amp;quot;MyTestFile.txt&amp;quot;)&lt;br /&gt;
 fileChanger.readFile();&lt;br /&gt;
 fileChanger.closeFile();&lt;br /&gt;
&lt;br /&gt;
== Comparison of Different Systems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''EasyMock'''===&lt;br /&gt;
*EasyMock has been the first dynamic Mock Object generator, relieving users of hand-writing Mock Objects, or generating code for them.&lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Supports re-factoring-safe Mock Objects&lt;br /&gt;
*Ability to return values and exceptions.&lt;br /&gt;
*Method order checking&lt;br /&gt;
http://easymock.org/&lt;br /&gt;
&lt;br /&gt;
==='''MOQ'''===&lt;br /&gt;
*Moq is the only mocking library for .NET developed from scratch to take full advantage of .NET 3.5 and C# 3.0 features.&lt;br /&gt;
*Supports mocking interfaces as well as classes. &lt;br /&gt;
*Supports the overriding of expectations where the test can set default expectations in a fixture setup, and override as needed on certain tests&lt;br /&gt;
*Intercept and raise events on mocks&lt;br /&gt;
http://code.google.com/p/moq/.&lt;br /&gt;
&lt;br /&gt;
==='''NMock'''===&lt;br /&gt;
*NMock is a dynamic mock object library for .NET. &lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Allows expectations to be defined and fails the test if any expectations are violated&lt;br /&gt;
*Expectations are specified beforehand and verified on the fly as the code under test is being executed, rather than afterward using assertions&lt;br /&gt;
*Implementations of interfaces are generate on the fly at runtime&lt;br /&gt;
http://www.nmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Rhino Mocks'''===&lt;br /&gt;
*Only supports mocks of interfaces, delegates and classes, including those with parametrized constructors.&lt;br /&gt;
*Expectations on the called methods by using strongly typed mocks instead of strings.&lt;br /&gt;
*Recursive mocking&lt;br /&gt;
http://ayende.com/projects/rhino-mocks.aspx&lt;br /&gt;
&lt;br /&gt;
==='''jMock'''===&lt;br /&gt;
*Forces test to be explicit about the argument values that will be passed to the expected methods&lt;br /&gt;
*Ability to write custom stubs, constraints, and Invocation Matchers&lt;br /&gt;
*Works well with the auto completion and refactoring features of your IDE&lt;br /&gt;
http://www.jmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Mocha'''===&lt;br /&gt;
*Similar to jMock only for Ruby &lt;br /&gt;
*Supports testing frameworks: Test::Unit, RSpec, test/spec, expectations, Dust, MiniTest and JtestR.&lt;br /&gt;
http://mocha.rubyforge.org/&lt;br /&gt;
&lt;br /&gt;
==='''Test::MockObject'''===&lt;br /&gt;
*Similar to jMock only for Perl&lt;br /&gt;
*Simple testing techniques&lt;br /&gt;
http://search.cpan.org/dist/Test-MockObject/lib/Test/MockObject.pm&lt;br /&gt;
&lt;br /&gt;
==='''JMockit'''===&lt;br /&gt;
&lt;br /&gt;
*Simpler and more succinct APIs for writing tests with behavior verification or state verification&lt;br /&gt;
*Provides other tools for supporting the creation of large test suites&lt;br /&gt;
*Uses class remapping instead of the original proxy dependencies&lt;br /&gt;
https://jmockit.dev.java.net/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
A mock object framework can make sure that the method under test, when executed, will in fact call certain functions on the mock object  and that the method under test will react in an appropriate way to whatever the mock objects do. Most parts of a software system do not work in isolation, but collaborate with other parts to get their job done. Writing tests provides a framework to think about functionality, Mock Objects provides a framework for making assertions about those relationships and for simulating responses. Mock Objects also allows programmers to make their tests only as precise as they need to be.&lt;br /&gt;
&lt;br /&gt;
The different frameworks provide a myriad of options for software developers to produce the correct mock tests for their software. The more complex the system, the more important it is when selecting the mock framework. Support for the framework is essential as well. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
1. [http://www.sizovpoint.com/2009/03/java-mock-frameworks-comparison.html Java Mock Framework Comparisons]&lt;br /&gt;
&lt;br /&gt;
2. [http://msdn.microsoft.com/en-us/magazine/dd882516.aspx Using Mocks And Tests To Design Role-Based Objects]&lt;br /&gt;
&lt;br /&gt;
3. [http://en.wikipedia.org/wiki/Mock_object Wikipedia - Mock object]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19686</id>
		<title>CSC/ECE 517 Fall 2009/wiki1a 2 sn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19686"/>
		<updated>2009-09-17T11:55:40Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Comparison of Mock Frameworks ==&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. A computer programmer typically creates a mock object to test the behavior of some other object, in much the same way that a car designer uses a crash test dummy to simulate the dynamic behavior of a human in vehicle impacts. [http://en.wikipedia.org/wiki/Mock_object 3]&lt;br /&gt;
&lt;br /&gt;
Mock frameworks are the environments that are available to create these mock objects and mock tests. &lt;br /&gt;
There are many different types of frameworks for different platforms. They are a set of programmable APIs that allow creation of mock and stub objects in relative easy fashion. Mock frameworks save the developer from the need to write repetitive code to test or simulate object interactions.&lt;br /&gt;
&lt;br /&gt;
== Concepts ==&lt;br /&gt;
&lt;br /&gt;
==='''Why Mock?'''===&lt;br /&gt;
&lt;br /&gt;
*The concept behind mock objects is that there is a need to create an object that will take the place of the real object. This mock object will expect a certain method to be called with certain parameters and when that happens, it will return an expected result. When writing units tests for a class that would normally use the real object, we can instead supply it with a mock object. This allows us a new level of flexibility in testing.[http://www.michaelminella.com/testing/the-concept-of-mocking.html 1]&lt;br /&gt;
&lt;br /&gt;
*Ease of modifying the mock object during separate tests to get it to get it to return a range of different data. Test can pass in valid, invalid, and extreme ranges to test how the code calling it handles such situations.[http://www.michaelminella.com/testing/the-concept-of-mocking.html 1]&lt;br /&gt;
&lt;br /&gt;
*Simulation of failures, such as the inability to connect to a database, to test the failure mode of classes.&lt;br /&gt;
&lt;br /&gt;
*Encourages better structured tests and, more importantly, improved domain code by preserving encapsulation, reducing dependencies and clarifying the interactions between classes. A running Object-Oriented program is a web of objects that collaborate by calling methods on each other. There sometimes can be many dependencies that have to be met in order to call certain objects. To make the complex dependencies be easily testable, mock objects are created in order to “mock” the stages that the object needs to be in, in order to call upon another object.&lt;br /&gt;
&lt;br /&gt;
*Often times in programming, only the changes in state of an object are tested. This would be acceptable only if there was one object. However, many real world applications contain hundreds upon hundreds of different objects. Mock objects have changed the focus of test from thinking about the changes in state of an object to thinking about its interactions with other objects.[http://msdn.microsoft.com/en-us/magazine/dd882516.aspx 2]&lt;br /&gt;
&lt;br /&gt;
==='''Different Types'''===&lt;br /&gt;
&lt;br /&gt;
====Proxy====&lt;br /&gt;
A proxy object is an object that is used to take the place of a real object. This is the original concept for all mock frameworks. In the case of mock objects, a proxy object is used to imitate the real object your code is dependent on. The proxy object is created with the mocking framework, and then set it on the object using either a setter or constructor. One has to be able to set the dependency up through an external means. This is one of the reasons Dependency Injection frameworks like [http://en.wikipedia.org/wiki/Spring_Framework Java Spring] have increase in popularity because they allow the ability to inject the proxy objects without modifying code.&lt;br /&gt;
[http://www.carlosble.com/?p=348 Proxy]&lt;br /&gt;
&lt;br /&gt;
====Class Remapping====&lt;br /&gt;
The second form of mocking is to remap the class file in the class loader. The concept is relatively new and is provided by the new java.lang.Instrument class. The basic idea is that the framework tells the class loader to remap the reference to another class file it will load which will be the mocked class. This allows one to be able to mock objects that are created by using the new operator much like other Object Oriented languages. Although this approach provides more functionality than the proxy object approach, it is much more complex and harder to write and fully understand.&lt;br /&gt;
[http://download.oracle.com/docs/cd/E13189_01/kodo/docs324/ref_guide_mapping_classmapping.html Class Mapping]&lt;br /&gt;
&lt;br /&gt;
== Examples of Mocking ==&lt;br /&gt;
&lt;br /&gt;
Lets say you have a an interface that looks like this:&lt;br /&gt;
&lt;br /&gt;
public interface FileInterface &lt;br /&gt;
{&lt;br /&gt;
  public void openFile(String filename) ;&lt;br /&gt;
  public void closeFile() ;&lt;br /&gt;
  public String readFile() ;    &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
== Comparison of Different Systems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''EasyMock'''===&lt;br /&gt;
*EasyMock has been the first dynamic Mock Object generator, relieving users of hand-writing Mock Objects, or generating code for them.&lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Supports re-factoring-safe Mock Objects&lt;br /&gt;
*Ability to return values and exceptions.&lt;br /&gt;
*Method order checking&lt;br /&gt;
http://easymock.org/&lt;br /&gt;
&lt;br /&gt;
==='''MOQ'''===&lt;br /&gt;
*Moq is the only mocking library for .NET developed from scratch to take full advantage of .NET 3.5 and C# 3.0 features.&lt;br /&gt;
*Supports mocking interfaces as well as classes. &lt;br /&gt;
*Supports the overriding of expectations where the test can set default expectations in a fixture setup, and override as needed on certain tests&lt;br /&gt;
*Intercept and raise events on mocks&lt;br /&gt;
http://code.google.com/p/moq/.&lt;br /&gt;
&lt;br /&gt;
==='''NMock'''===&lt;br /&gt;
*NMock is a dynamic mock object library for .NET. &lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Allows expectations to be defined and fails the test if any expectations are violated&lt;br /&gt;
*Expectations are specified beforehand and verified on the fly as the code under test is being executed, rather than afterward using assertions&lt;br /&gt;
*Implementations of interfaces are generate on the fly at runtime&lt;br /&gt;
http://www.nmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Rhino Mocks'''===&lt;br /&gt;
*Only supports mocks of interfaces, delegates and classes, including those with parametrized constructors.&lt;br /&gt;
*Expectations on the called methods by using strongly typed mocks instead of strings.&lt;br /&gt;
*Recursive mocking&lt;br /&gt;
http://ayende.com/projects/rhino-mocks.aspx&lt;br /&gt;
&lt;br /&gt;
==='''jMock'''===&lt;br /&gt;
*Forces test to be explicit about the argument values that will be passed to the expected methods&lt;br /&gt;
*Ability to write custom stubs, constraints, and Invocation Matchers&lt;br /&gt;
*Works well with the auto completion and refactoring features of your IDE&lt;br /&gt;
http://www.jmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Mocha'''===&lt;br /&gt;
*Similar to jMock only for Ruby &lt;br /&gt;
*Supports testing frameworks: Test::Unit, RSpec, test/spec, expectations, Dust, MiniTest and JtestR.&lt;br /&gt;
http://mocha.rubyforge.org/&lt;br /&gt;
&lt;br /&gt;
==='''Test::MockObject'''===&lt;br /&gt;
*Similar to jMock only for Perl&lt;br /&gt;
*Simple testing techniques&lt;br /&gt;
http://search.cpan.org/dist/Test-MockObject/lib/Test/MockObject.pm&lt;br /&gt;
&lt;br /&gt;
==='''JMockit'''===&lt;br /&gt;
&lt;br /&gt;
*Simpler and more succinct APIs for writing tests with behavior verification or state verification&lt;br /&gt;
*Provides other tools for supporting the creation of large test suites&lt;br /&gt;
*Uses class remapping instead of the original proxy dependencies&lt;br /&gt;
https://jmockit.dev.java.net/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
A mock object framework can make sure that the method under test, when executed, will in fact call certain functions on the mock object  and that the method under test will react in an appropriate way to whatever the mock objects do. Most parts of a software system do not work in isolation, but collaborate with other parts to get their job done. Writing tests provides a framework to think about functionality, Mock Objects provides a framework for making assertions about those relationships and for simulating responses. Mock Objects also allows programmers to make their tests only as precise as they need to be.&lt;br /&gt;
&lt;br /&gt;
The different frameworks provide a myriad of options for software developers to produce the correct mock tests for their software. The more complex the system, the more important it is when selecting the mock framework. Support for the framework is essential as well. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
1. [http://www.sizovpoint.com/2009/03/java-mock-frameworks-comparison.html Java Mock Framework Comparisons]&lt;br /&gt;
&lt;br /&gt;
2. [http://msdn.microsoft.com/en-us/magazine/dd882516.aspx Using Mocks And Tests To Design Role-Based Objects]&lt;br /&gt;
&lt;br /&gt;
3. [http://en.wikipedia.org/wiki/Mock_object Wikipedia - Mock object]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19685</id>
		<title>CSC/ECE 517 Fall 2009/wiki1a 2 sn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19685"/>
		<updated>2009-09-17T11:43:48Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Comparison of Mock Frameworks ==&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. A computer programmer typically creates a mock object to test the behavior of some other object, in much the same way that a car designer uses a crash test dummy to simulate the dynamic behavior of a human in vehicle impacts. [http://en.wikipedia.org/wiki/Mock_object 3]&lt;br /&gt;
&lt;br /&gt;
Mock frameworks are the environments that are available to create these mock objects and mock tests. &lt;br /&gt;
There are many different types of frameworks for different platforms. They are a set of programmable APIs that allow creation of mock and stub objects in relative easy fashion. Mock frameworks save the developer from the need to write repetitive code to test or simulate object interactions.&lt;br /&gt;
&lt;br /&gt;
== Concepts ==&lt;br /&gt;
&lt;br /&gt;
==='''Why Mock?'''===&lt;br /&gt;
&lt;br /&gt;
*The concept behind mock objects is that there is a need to create an object that will take the place of the real object. This mock object will expect a certain method to be called with certain parameters and when that happens, it will return an expected result. When writing units tests for a class that would normally use the real object, we can instead supply it with a mock object. This allows us a new level of flexibility in testing.[http://www.michaelminella.com/testing/the-concept-of-mocking.html 1]&lt;br /&gt;
&lt;br /&gt;
*Ease of modifying the mock object during separate tests to get it to get it to return a range of different data. Test can pass in valid, invalid, and extreme ranges to test how the code calling it handles such situations.[http://www.michaelminella.com/testing/the-concept-of-mocking.html 1]&lt;br /&gt;
&lt;br /&gt;
*Simulation of failures, such as the inability to connect to a database, to test the failure mode of classes.&lt;br /&gt;
&lt;br /&gt;
*Encourages better structured tests and, more importantly, improved domain code by preserving encapsulation, reducing dependencies and clarifying the interactions between classes. A running Object-Oriented program is a web of objects that collaborate by calling methods on each other. There sometimes can be many dependencies that have to be met in order to call certain objects. To make the complex dependencies be easily testable, mock objects are created in order to “mock” the stages that the object needs to be in, in order to call upon another object.&lt;br /&gt;
&lt;br /&gt;
*Often times in programming, only the changes in state of an object are tested. This would be acceptable only if there was one object. However, many real world applications contain hundreds upon hundreds of different objects. Mock objects have changed the focus of test from thinking about the changes in state of an object to thinking about its interactions with other objects.[http://msdn.microsoft.com/en-us/magazine/dd882516.aspx 2]&lt;br /&gt;
&lt;br /&gt;
==='''Different Types'''===&lt;br /&gt;
&lt;br /&gt;
====Proxy====&lt;br /&gt;
A proxy object is an object that is used to take the place of a real object. This is the original concept for all mock frameworks. In the case of mock objects, a proxy object is used to imitate the real object your code is dependent on. The proxy object is created with the mocking framework, and then set it on the object using either a setter or constructor. One has to be able to set the dependency up through an external means. This is one of the reasons Dependency Injection frameworks like [http://en.wikipedia.org/wiki/Spring_Framework Java Spring] have increase in popularity because they allow the ability to inject the proxy objects without modifying code.&lt;br /&gt;
[http://www.carlosble.com/?p=348 Proxy]&lt;br /&gt;
&lt;br /&gt;
====Class Remapping====&lt;br /&gt;
The second form of mocking is to remap the class file in the class loader. The concept is relatively new and is provided by the new java.lang.Instrument class. The basic idea is that the framework tells the class loader to remap the reference to another class file it will load which will be the mocked class. This allows one to be able to mock objects that are created by using the new operator much like other Object Oriented languages. Although this approach provides more functionality than the proxy object approach, it is much more complex and harder to write and fully understand.&lt;br /&gt;
[http://download.oracle.com/docs/cd/E13189_01/kodo/docs324/ref_guide_mapping_classmapping.html Class Mapping]&lt;br /&gt;
&lt;br /&gt;
== Comparison of Different Systems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''EasyMock'''===&lt;br /&gt;
*EasyMock has been the first dynamic Mock Object generator, relieving users of hand-writing Mock Objects, or generating code for them.&lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Supports re-factoring-safe Mock Objects&lt;br /&gt;
*Ability to return values and exceptions.&lt;br /&gt;
*Method order checking&lt;br /&gt;
http://easymock.org/&lt;br /&gt;
&lt;br /&gt;
==='''MOQ'''===&lt;br /&gt;
*Moq is the only mocking library for .NET developed from scratch to take full advantage of .NET 3.5 and C# 3.0 features.&lt;br /&gt;
*Supports mocking interfaces as well as classes. &lt;br /&gt;
*Supports the overriding of expectations where the test can set default expectations in a fixture setup, and override as needed on certain tests&lt;br /&gt;
*Intercept and raise events on mocks&lt;br /&gt;
http://code.google.com/p/moq/.&lt;br /&gt;
&lt;br /&gt;
==='''NMock'''===&lt;br /&gt;
*NMock is a dynamic mock object library for .NET. &lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Allows expectations to be defined and fails the test if any expectations are violated&lt;br /&gt;
*Expectations are specified beforehand and verified on the fly as the code under test is being executed, rather than afterward using assertions&lt;br /&gt;
*Implementations of interfaces are generate on the fly at runtime&lt;br /&gt;
http://www.nmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Rhino Mocks'''===&lt;br /&gt;
*Only supports mocks of interfaces, delegates and classes, including those with parametrized constructors.&lt;br /&gt;
*Expectations on the called methods by using strongly typed mocks instead of strings.&lt;br /&gt;
*Recursive mocking&lt;br /&gt;
http://ayende.com/projects/rhino-mocks.aspx&lt;br /&gt;
&lt;br /&gt;
==='''jMock'''===&lt;br /&gt;
*Forces test to be explicit about the argument values that will be passed to the expected methods&lt;br /&gt;
*Ability to write custom stubs, constraints, and Invocation Matchers&lt;br /&gt;
*Works well with the auto completion and refactoring features of your IDE&lt;br /&gt;
http://www.jmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Mocha'''===&lt;br /&gt;
*Similar to jMock only for Ruby &lt;br /&gt;
*Supports testing frameworks: Test::Unit, RSpec, test/spec, expectations, Dust, MiniTest and JtestR.&lt;br /&gt;
http://mocha.rubyforge.org/&lt;br /&gt;
&lt;br /&gt;
==='''Test::MockObject'''===&lt;br /&gt;
*Similar to jMock only for Perl&lt;br /&gt;
*Simple testing techniques&lt;br /&gt;
http://search.cpan.org/dist/Test-MockObject/lib/Test/MockObject.pm&lt;br /&gt;
&lt;br /&gt;
==='''JMockit'''===&lt;br /&gt;
&lt;br /&gt;
*Simpler and more succinct APIs for writing tests with behavior verification or state verification&lt;br /&gt;
*Provides other tools for supporting the creation of large test suites&lt;br /&gt;
*Uses class remapping instead of the original proxy dependencies&lt;br /&gt;
https://jmockit.dev.java.net/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
A mock object framework can make sure that the method under test, when executed, will in fact call certain functions on the mock object  and that the method under test will react in an appropriate way to whatever the mock objects do. Most parts of a software system do not work in isolation, but collaborate with other parts to get their job done. Writing tests provides a framework to think about functionality, Mock Objects provides a framework for making assertions about those relationships and for simulating responses. Mock Objects also allows programmers to make their tests only as precise as they need to be.&lt;br /&gt;
&lt;br /&gt;
The different frameworks provide a myriad of options for software developers to produce the correct mock tests for their software. The more complex the system, the more important it is when selecting the mock framework. Support for the framework is essential as well. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
1. [http://www.sizovpoint.com/2009/03/java-mock-frameworks-comparison.html Java Mock Framework Comparisons]&lt;br /&gt;
&lt;br /&gt;
2. [http://msdn.microsoft.com/en-us/magazine/dd882516.aspx Using Mocks And Tests To Design Role-Based Objects]&lt;br /&gt;
&lt;br /&gt;
3. [http://en.wikipedia.org/wiki/Mock_object Wikipedia - Mock object]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19684</id>
		<title>CSC/ECE 517 Fall 2009/wiki1a 2 sn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19684"/>
		<updated>2009-09-17T11:42:12Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: /* '''Why Mock?''' */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Comparison of Mock Frameworks ==&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. A computer programmer typically creates a mock object to test the behavior of some other object, in much the same way that a car designer uses a crash test dummy to simulate the dynamic behavior of a human in vehicle impacts. [FROM http://en.wikipedia.org/wiki/Mock_object ]&lt;br /&gt;
&lt;br /&gt;
Mock frameworks are the environments that are available to create these mock objects and mock tests. &lt;br /&gt;
There are many different types of frameworks for different platforms. They are a set of programmable APIs that allow creation of mock and stub objects in relative easy fashion. Mock frameworks save the developer from the need to write repetitive code to test or simulate object interactions.&lt;br /&gt;
&lt;br /&gt;
== Concepts ==&lt;br /&gt;
&lt;br /&gt;
==='''Why Mock?'''===&lt;br /&gt;
&lt;br /&gt;
*The concept behind mock objects is that there is a need to create an object that will take the place of the real object. This mock object will expect a certain method to be called with certain parameters and when that happens, it will return an expected result. When writing units tests for a class that would normally use the real object, we can instead supply it with a mock object. This allows us a new level of flexibility in testing.[1 http://www.michaelminella.com/testing/the-concept-of-mocking.html]&lt;br /&gt;
&lt;br /&gt;
*Ease of modifying the mock object during separate tests to get it to get it to return a range of different data. Test can pass in valid, invalid, and extreme ranges to test how the code calling it handles such situations.[1 http://www.michaelminella.com/testing/the-concept-of-mocking.html]&lt;br /&gt;
&lt;br /&gt;
*Simulation of failures, such as the inability to connect to a database, to test the failure mode of classes.&lt;br /&gt;
&lt;br /&gt;
*Encourages better structured tests and, more importantly, improved domain code by preserving encapsulation, reducing dependencies and clarifying the interactions between classes. A running Object-Oriented program is a web of objects that collaborate by calling methods on each other. There sometimes can be many dependencies that have to be met in order to call certain objects. To make the complex dependencies be easily testable, mock objects are created in order to “mock” the stages that the object needs to be in, in order to call upon another object.&lt;br /&gt;
&lt;br /&gt;
*Often times in programming, only the changes in state of an object are tested. This would be acceptable only if there was one object. However, many real world applications contain hundreds upon hundreds of different objects. Mock objects have changed the focus of test from thinking about the changes in state of an object to thinking about its interactions with other objects.&lt;br /&gt;
&lt;br /&gt;
==='''Different Types'''===&lt;br /&gt;
&lt;br /&gt;
====Proxy====&lt;br /&gt;
A proxy object is an object that is used to take the place of a real object. This is the original concept for all mock frameworks. In the case of mock objects, a proxy object is used to imitate the real object your code is dependent on. The proxy object is created with the mocking framework, and then set it on the object using either a setter or constructor. One has to be able to set the dependency up through an external means. This is one of the reasons Dependency Injection frameworks like [http://en.wikipedia.org/wiki/Spring_Framework Java Spring] have increase in popularity because they allow the ability to inject the proxy objects without modifying code.&lt;br /&gt;
[http://www.carlosble.com/?p=348 Proxy]&lt;br /&gt;
&lt;br /&gt;
====Class Remapping====&lt;br /&gt;
The second form of mocking is to remap the class file in the class loader. The concept is relatively new and is provided by the new java.lang.Instrument class. The basic idea is that the framework tells the class loader to remap the reference to another class file it will load which will be the mocked class. This allows one to be able to mock objects that are created by using the new operator much like other Object Oriented languages. Although this approach provides more functionality than the proxy object approach, it is much more complex and harder to write and fully understand.&lt;br /&gt;
[http://download.oracle.com/docs/cd/E13189_01/kodo/docs324/ref_guide_mapping_classmapping.html Class Mapping]&lt;br /&gt;
&lt;br /&gt;
== Comparison of Different Systems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''EasyMock'''===&lt;br /&gt;
*EasyMock has been the first dynamic Mock Object generator, relieving users of hand-writing Mock Objects, or generating code for them.&lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Supports re-factoring-safe Mock Objects&lt;br /&gt;
*Ability to return values and exceptions.&lt;br /&gt;
*Method order checking&lt;br /&gt;
http://easymock.org/&lt;br /&gt;
&lt;br /&gt;
==='''MOQ'''===&lt;br /&gt;
*Moq is the only mocking library for .NET developed from scratch to take full advantage of .NET 3.5 and C# 3.0 features.&lt;br /&gt;
*Supports mocking interfaces as well as classes. &lt;br /&gt;
*Supports the overriding of expectations where the test can set default expectations in a fixture setup, and override as needed on certain tests&lt;br /&gt;
*Intercept and raise events on mocks&lt;br /&gt;
http://code.google.com/p/moq/.&lt;br /&gt;
&lt;br /&gt;
==='''NMock'''===&lt;br /&gt;
*NMock is a dynamic mock object library for .NET. &lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Allows expectations to be defined and fails the test if any expectations are violated&lt;br /&gt;
*Expectations are specified beforehand and verified on the fly as the code under test is being executed, rather than afterward using assertions&lt;br /&gt;
*Implementations of interfaces are generate on the fly at runtime&lt;br /&gt;
http://www.nmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Rhino Mocks'''===&lt;br /&gt;
*Only supports mocks of interfaces, delegates and classes, including those with parametrized constructors.&lt;br /&gt;
*Expectations on the called methods by using strongly typed mocks instead of strings.&lt;br /&gt;
*Recursive mocking&lt;br /&gt;
http://ayende.com/projects/rhino-mocks.aspx&lt;br /&gt;
&lt;br /&gt;
==='''jMock'''===&lt;br /&gt;
*Forces test to be explicit about the argument values that will be passed to the expected methods&lt;br /&gt;
*Ability to write custom stubs, constraints, and Invocation Matchers&lt;br /&gt;
*Works well with the auto completion and refactoring features of your IDE&lt;br /&gt;
http://www.jmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Mocha'''===&lt;br /&gt;
*Similar to jMock only for Ruby &lt;br /&gt;
*Supports testing frameworks: Test::Unit, RSpec, test/spec, expectations, Dust, MiniTest and JtestR.&lt;br /&gt;
http://mocha.rubyforge.org/&lt;br /&gt;
&lt;br /&gt;
==='''Test::MockObject'''===&lt;br /&gt;
*Similar to jMock only for Perl&lt;br /&gt;
*Simple testing techniques&lt;br /&gt;
http://search.cpan.org/dist/Test-MockObject/lib/Test/MockObject.pm&lt;br /&gt;
&lt;br /&gt;
==='''JMockit'''===&lt;br /&gt;
&lt;br /&gt;
*Simpler and more succinct APIs for writing tests with behavior verification or state verification&lt;br /&gt;
*Provides other tools for supporting the creation of large test suites&lt;br /&gt;
*Uses class remapping instead of the original proxy dependencies&lt;br /&gt;
https://jmockit.dev.java.net/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
A mock object framework can make sure that the method under test, when executed, will in fact call certain functions on the mock object  and that the method under test will react in an appropriate way to whatever the mock objects do. Most parts of a software system do not work in isolation, but collaborate with other parts to get their job done. Writing tests provides a framework to think about functionality, Mock Objects provides a framework for making assertions about those relationships and for simulating responses. Mock Objects also allows programmers to make their tests only as precise as they need to be.&lt;br /&gt;
&lt;br /&gt;
The different frameworks provide a myriad of options for software developers to produce the correct mock tests for their software. The more complex the system, the more important it is when selecting the mock framework. Support for the framework is essential as well. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
1. [http://www.sizovpoint.com/2009/03/java-mock-frameworks-comparison.html Java Mock Framework Comparisons]&lt;br /&gt;
&lt;br /&gt;
2. [http://msdn.microsoft.com/en-us/magazine/dd882516.aspx Using Mocks And Tests To Design Role-Based Objects]&lt;br /&gt;
&lt;br /&gt;
3. [http://en.wikipedia.org/wiki/Mock_object Wikipedia - Mock object]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19683</id>
		<title>CSC/ECE 517 Fall 2009/wiki1a 2 sn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19683"/>
		<updated>2009-09-17T11:38:30Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: /* Proxy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Comparison of Mock Frameworks ==&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. A computer programmer typically creates a mock object to test the behavior of some other object, in much the same way that a car designer uses a crash test dummy to simulate the dynamic behavior of a human in vehicle impacts. [FROM http://en.wikipedia.org/wiki/Mock_object ]&lt;br /&gt;
&lt;br /&gt;
Mock frameworks are the environments that are available to create these mock objects and mock tests. &lt;br /&gt;
There are many different types of frameworks for different platforms. They are a set of programmable APIs that allow creation of mock and stub objects in relative easy fashion. Mock frameworks save the developer from the need to write repetitive code to test or simulate object interactions.&lt;br /&gt;
&lt;br /&gt;
== Concepts ==&lt;br /&gt;
&lt;br /&gt;
==='''Why Mock?'''===&lt;br /&gt;
&lt;br /&gt;
*The concept behind mock objects is that there is a need to create an object that will take the place of the real object. This mock object will expect a certain method to be called with certain parameters and when that happens, it will return an expected result. When writing units tests for a class that would normally use the real object, we can instead supply it with a mock object. This allows us a new level of flexibility in testing.&lt;br /&gt;
&lt;br /&gt;
*Ease of modifying the mock object during separate tests to get it to get it to return a range of different data. Test can pass in valid, invalid, and extreme ranges to test how the code calling it handles such situations.&lt;br /&gt;
&lt;br /&gt;
*Simulation of failures, such as the inability to connect to a database, to test the failure mode of classes.&lt;br /&gt;
&lt;br /&gt;
*Encourages better structured tests and, more importantly, improved domain code by preserving encapsulation, reducing dependencies and clarifying the interactions between classes. A running Object-Oriented program is a web of objects that collaborate by calling methods on each other. There sometimes can be many dependencies that have to be met in order to call certain objects. To make the complex dependencies be easily testable, mock objects are created in order to “mock” the stages that the object needs to be in, in order to call upon another object.&lt;br /&gt;
&lt;br /&gt;
*Often times in programming, only the changes in state of an object are tested. This would be acceptable only if there was one object. However, many real world applications contain hundreds upon hundreds of different objects. Mock objects have changed the focus of test from thinking about the changes in state of an object to thinking about its interactions with other objects.&lt;br /&gt;
&lt;br /&gt;
==='''Different Types'''===&lt;br /&gt;
&lt;br /&gt;
====Proxy====&lt;br /&gt;
A proxy object is an object that is used to take the place of a real object. This is the original concept for all mock frameworks. In the case of mock objects, a proxy object is used to imitate the real object your code is dependent on. The proxy object is created with the mocking framework, and then set it on the object using either a setter or constructor. One has to be able to set the dependency up through an external means. This is one of the reasons Dependency Injection frameworks like [http://en.wikipedia.org/wiki/Spring_Framework Java Spring] have increase in popularity because they allow the ability to inject the proxy objects without modifying code.&lt;br /&gt;
[http://www.carlosble.com/?p=348 Proxy]&lt;br /&gt;
&lt;br /&gt;
====Class Remapping====&lt;br /&gt;
The second form of mocking is to remap the class file in the class loader. The concept is relatively new and is provided by the new java.lang.Instrument class. The basic idea is that the framework tells the class loader to remap the reference to another class file it will load which will be the mocked class. This allows one to be able to mock objects that are created by using the new operator much like other Object Oriented languages. Although this approach provides more functionality than the proxy object approach, it is much more complex and harder to write and fully understand.&lt;br /&gt;
[http://download.oracle.com/docs/cd/E13189_01/kodo/docs324/ref_guide_mapping_classmapping.html Class Mapping]&lt;br /&gt;
&lt;br /&gt;
== Comparison of Different Systems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''EasyMock'''===&lt;br /&gt;
*EasyMock has been the first dynamic Mock Object generator, relieving users of hand-writing Mock Objects, or generating code for them.&lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Supports re-factoring-safe Mock Objects&lt;br /&gt;
*Ability to return values and exceptions.&lt;br /&gt;
*Method order checking&lt;br /&gt;
http://easymock.org/&lt;br /&gt;
&lt;br /&gt;
==='''MOQ'''===&lt;br /&gt;
*Moq is the only mocking library for .NET developed from scratch to take full advantage of .NET 3.5 and C# 3.0 features.&lt;br /&gt;
*Supports mocking interfaces as well as classes. &lt;br /&gt;
*Supports the overriding of expectations where the test can set default expectations in a fixture setup, and override as needed on certain tests&lt;br /&gt;
*Intercept and raise events on mocks&lt;br /&gt;
http://code.google.com/p/moq/.&lt;br /&gt;
&lt;br /&gt;
==='''NMock'''===&lt;br /&gt;
*NMock is a dynamic mock object library for .NET. &lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Allows expectations to be defined and fails the test if any expectations are violated&lt;br /&gt;
*Expectations are specified beforehand and verified on the fly as the code under test is being executed, rather than afterward using assertions&lt;br /&gt;
*Implementations of interfaces are generate on the fly at runtime&lt;br /&gt;
http://www.nmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Rhino Mocks'''===&lt;br /&gt;
*Only supports mocks of interfaces, delegates and classes, including those with parametrized constructors.&lt;br /&gt;
*Expectations on the called methods by using strongly typed mocks instead of strings.&lt;br /&gt;
*Recursive mocking&lt;br /&gt;
http://ayende.com/projects/rhino-mocks.aspx&lt;br /&gt;
&lt;br /&gt;
==='''jMock'''===&lt;br /&gt;
*Forces test to be explicit about the argument values that will be passed to the expected methods&lt;br /&gt;
*Ability to write custom stubs, constraints, and Invocation Matchers&lt;br /&gt;
*Works well with the auto completion and refactoring features of your IDE&lt;br /&gt;
http://www.jmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Mocha'''===&lt;br /&gt;
*Similar to jMock only for Ruby &lt;br /&gt;
*Supports testing frameworks: Test::Unit, RSpec, test/spec, expectations, Dust, MiniTest and JtestR.&lt;br /&gt;
http://mocha.rubyforge.org/&lt;br /&gt;
&lt;br /&gt;
==='''Test::MockObject'''===&lt;br /&gt;
*Similar to jMock only for Perl&lt;br /&gt;
*Simple testing techniques&lt;br /&gt;
http://search.cpan.org/dist/Test-MockObject/lib/Test/MockObject.pm&lt;br /&gt;
&lt;br /&gt;
==='''JMockit'''===&lt;br /&gt;
&lt;br /&gt;
*Simpler and more succinct APIs for writing tests with behavior verification or state verification&lt;br /&gt;
*Provides other tools for supporting the creation of large test suites&lt;br /&gt;
*Uses class remapping instead of the original proxy dependencies&lt;br /&gt;
https://jmockit.dev.java.net/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
A mock object framework can make sure that the method under test, when executed, will in fact call certain functions on the mock object  and that the method under test will react in an appropriate way to whatever the mock objects do. Most parts of a software system do not work in isolation, but collaborate with other parts to get their job done. Writing tests provides a framework to think about functionality, Mock Objects provides a framework for making assertions about those relationships and for simulating responses. Mock Objects also allows programmers to make their tests only as precise as they need to be.&lt;br /&gt;
&lt;br /&gt;
The different frameworks provide a myriad of options for software developers to produce the correct mock tests for their software. The more complex the system, the more important it is when selecting the mock framework. Support for the framework is essential as well. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
1. [http://www.sizovpoint.com/2009/03/java-mock-frameworks-comparison.html Java Mock Framework Comparisons]&lt;br /&gt;
&lt;br /&gt;
2. [http://msdn.microsoft.com/en-us/magazine/dd882516.aspx Using Mocks And Tests To Design Role-Based Objects]&lt;br /&gt;
&lt;br /&gt;
3. [http://en.wikipedia.org/wiki/Mock_object Wikipedia - Mock object]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19681</id>
		<title>CSC/ECE 517 Fall 2009/wiki1a 2 sn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19681"/>
		<updated>2009-09-17T11:35:25Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Comparison of Mock Frameworks ==&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. A computer programmer typically creates a mock object to test the behavior of some other object, in much the same way that a car designer uses a crash test dummy to simulate the dynamic behavior of a human in vehicle impacts. [FROM http://en.wikipedia.org/wiki/Mock_object ]&lt;br /&gt;
&lt;br /&gt;
Mock frameworks are the environments that are available to create these mock objects and mock tests. &lt;br /&gt;
There are many different types of frameworks for different platforms. They are a set of programmable APIs that allow creation of mock and stub objects in relative easy fashion. Mock frameworks save the developer from the need to write repetitive code to test or simulate object interactions.&lt;br /&gt;
&lt;br /&gt;
== Concepts ==&lt;br /&gt;
&lt;br /&gt;
==='''Why Mock?'''===&lt;br /&gt;
&lt;br /&gt;
*The concept behind mock objects is that there is a need to create an object that will take the place of the real object. This mock object will expect a certain method to be called with certain parameters and when that happens, it will return an expected result. When writing units tests for a class that would normally use the real object, we can instead supply it with a mock object. This allows us a new level of flexibility in testing.&lt;br /&gt;
&lt;br /&gt;
*Ease of modifying the mock object during separate tests to get it to get it to return a range of different data. Test can pass in valid, invalid, and extreme ranges to test how the code calling it handles such situations.&lt;br /&gt;
&lt;br /&gt;
*Simulation of failures, such as the inability to connect to a database, to test the failure mode of classes.&lt;br /&gt;
&lt;br /&gt;
*Encourages better structured tests and, more importantly, improved domain code by preserving encapsulation, reducing dependencies and clarifying the interactions between classes. A running Object-Oriented program is a web of objects that collaborate by calling methods on each other. There sometimes can be many dependencies that have to be met in order to call certain objects. To make the complex dependencies be easily testable, mock objects are created in order to “mock” the stages that the object needs to be in, in order to call upon another object.&lt;br /&gt;
&lt;br /&gt;
*Often times in programming, only the changes in state of an object are tested. This would be acceptable only if there was one object. However, many real world applications contain hundreds upon hundreds of different objects. Mock objects have changed the focus of test from thinking about the changes in state of an object to thinking about its interactions with other objects.&lt;br /&gt;
&lt;br /&gt;
==='''Different Types'''===&lt;br /&gt;
&lt;br /&gt;
====Proxy====&lt;br /&gt;
A proxy object is an object that is used to take the place of a real object. This is the original concept for all mock frameworks. In the case of mock objects, a proxy object is used to imitate the real object your code is dependent on. The proxy object is created with the mocking framework, and then set it on the object using either a setter or constructor. One has to be able to set the dependency up through an external means. This is one of the reasons Dependency Injection frameworks like Java Spring have increase in popularity because they allow the ability to inject the proxy objects without modifying code.&lt;br /&gt;
[http://www.carlosble.com/?p=348 Proxy]&lt;br /&gt;
&lt;br /&gt;
====Class Remapping====&lt;br /&gt;
The second form of mocking is to remap the class file in the class loader. The concept is relatively new and is provided by the new java.lang.Instrument class. The basic idea is that the framework tells the class loader to remap the reference to another class file it will load which will be the mocked class. This allows one to be able to mock objects that are created by using the new operator much like other Object Oriented languages. Although this approach provides more functionality than the proxy object approach, it is much more complex and harder to write and fully understand.&lt;br /&gt;
[http://download.oracle.com/docs/cd/E13189_01/kodo/docs324/ref_guide_mapping_classmapping.html Class Mapping]&lt;br /&gt;
&lt;br /&gt;
== Comparison of Different Systems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''EasyMock'''===&lt;br /&gt;
*EasyMock has been the first dynamic Mock Object generator, relieving users of hand-writing Mock Objects, or generating code for them.&lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Supports re-factoring-safe Mock Objects&lt;br /&gt;
*Ability to return values and exceptions.&lt;br /&gt;
*Method order checking&lt;br /&gt;
http://easymock.org/&lt;br /&gt;
&lt;br /&gt;
==='''MOQ'''===&lt;br /&gt;
*Moq is the only mocking library for .NET developed from scratch to take full advantage of .NET 3.5 and C# 3.0 features.&lt;br /&gt;
*Supports mocking interfaces as well as classes. &lt;br /&gt;
*Supports the overriding of expectations where the test can set default expectations in a fixture setup, and override as needed on certain tests&lt;br /&gt;
*Intercept and raise events on mocks&lt;br /&gt;
http://code.google.com/p/moq/.&lt;br /&gt;
&lt;br /&gt;
==='''NMock'''===&lt;br /&gt;
*NMock is a dynamic mock object library for .NET. &lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Allows expectations to be defined and fails the test if any expectations are violated&lt;br /&gt;
*Expectations are specified beforehand and verified on the fly as the code under test is being executed, rather than afterward using assertions&lt;br /&gt;
*Implementations of interfaces are generate on the fly at runtime&lt;br /&gt;
http://www.nmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Rhino Mocks'''===&lt;br /&gt;
*Only supports mocks of interfaces, delegates and classes, including those with parametrized constructors.&lt;br /&gt;
*Expectations on the called methods by using strongly typed mocks instead of strings.&lt;br /&gt;
*Recursive mocking&lt;br /&gt;
http://ayende.com/projects/rhino-mocks.aspx&lt;br /&gt;
&lt;br /&gt;
==='''jMock'''===&lt;br /&gt;
*Forces test to be explicit about the argument values that will be passed to the expected methods&lt;br /&gt;
*Ability to write custom stubs, constraints, and Invocation Matchers&lt;br /&gt;
*Works well with the auto completion and refactoring features of your IDE&lt;br /&gt;
http://www.jmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Mocha'''===&lt;br /&gt;
*Similar to jMock only for Ruby &lt;br /&gt;
*Supports testing frameworks: Test::Unit, RSpec, test/spec, expectations, Dust, MiniTest and JtestR.&lt;br /&gt;
http://mocha.rubyforge.org/&lt;br /&gt;
&lt;br /&gt;
==='''Test::MockObject'''===&lt;br /&gt;
*Similar to jMock only for Perl&lt;br /&gt;
*Simple testing techniques&lt;br /&gt;
http://search.cpan.org/dist/Test-MockObject/lib/Test/MockObject.pm&lt;br /&gt;
&lt;br /&gt;
==='''JMockit'''===&lt;br /&gt;
&lt;br /&gt;
*Simpler and more succinct APIs for writing tests with behavior verification or state verification&lt;br /&gt;
*Provides other tools for supporting the creation of large test suites&lt;br /&gt;
*Uses class remapping instead of the original proxy dependencies&lt;br /&gt;
https://jmockit.dev.java.net/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
A mock object framework can make sure that the method under test, when executed, will in fact call certain functions on the mock object  and that the method under test will react in an appropriate way to whatever the mock objects do. Most parts of a software system do not work in isolation, but collaborate with other parts to get their job done. Writing tests provides a framework to think about functionality, Mock Objects provides a framework for making assertions about those relationships and for simulating responses. Mock Objects also allows programmers to make their tests only as precise as they need to be.&lt;br /&gt;
&lt;br /&gt;
The different frameworks provide a myriad of options for software developers to produce the correct mock tests for their software. The more complex the system, the more important it is when selecting the mock framework. Support for the framework is essential as well. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
1. [http://www.sizovpoint.com/2009/03/java-mock-frameworks-comparison.html Java Mock Framework Comparisons]&lt;br /&gt;
&lt;br /&gt;
2. [http://msdn.microsoft.com/en-us/magazine/dd882516.aspx Using Mocks And Tests To Design Role-Based Objects]&lt;br /&gt;
&lt;br /&gt;
3. [http://en.wikipedia.org/wiki/Mock_object Wikipedia - Mock object]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19160</id>
		<title>CSC/ECE 517 Fall 2009/wiki1a 2 sn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19160"/>
		<updated>2009-09-14T16:11:23Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: /* Comparison of Mock Frameworks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Comparison of Mock Frameworks ==&lt;br /&gt;
'''NOTE:''' THIS SECTION WILL BE REMOVED FROM THE FINAL VERSION&lt;br /&gt;
&lt;br /&gt;
Assignment:&lt;br /&gt;
Mock objects and mock frameworks.  When performing tests, it's convenient to have the objects be in a particular configuration, so that boundary cases can be tested.  Setting up the objects can sometimes be complicated.  The Wikipedia article for mock objects lists several, but does not compare them.  Compare different systems for mock objects, and mock frameworks (which are used to set up mock objects).&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. A computer programmer typically creates a mock object to test the behavior of some other object, in much the same way that a car designer uses a crash test dummy to simulate the dynamic behavior of a human in vehicle impacts. [FROM http://en.wikipedia.org/wiki/Mock_object ]&lt;br /&gt;
&lt;br /&gt;
Mock frameworks are the environments that are available to create these mock objects and mock tests. &lt;br /&gt;
There are many different types of frameworks for different platforms. They are a set of programmable APIs that allow creation of mock and stub objects in relative easy fashion. Mock frameworks save the developer from the need to write repetitive code to test or simulate object interactions.&lt;br /&gt;
&lt;br /&gt;
== Concepts ==&lt;br /&gt;
&lt;br /&gt;
==='''Why Mock?'''===&lt;br /&gt;
&lt;br /&gt;
*The concept behind mock objects is that there is a need to create an object that will take the place of the real object. This mock object will expect a certain method to be called with certain parameters and when that happens, it will return an expected result. When writing units tests for a class that would normally use the real object, we can instead supply it with a mock object. This allows us a new level of flexibility in testing.&lt;br /&gt;
&lt;br /&gt;
*Ease of modifying the mock object during separate tests to get it to get it to return a range of different data. Test can pass in valid, invalid, and extreme ranges to test how the code calling it handles such situations.&lt;br /&gt;
&lt;br /&gt;
*Simulation of failures, such as the inability to connect to a database, to test the failure mode of classes.&lt;br /&gt;
&lt;br /&gt;
*Encourages better structured tests and, more importantly, improved domain code by preserving encapsulation, reducing dependencies and clarifying the interactions between classes. A running Object-Oriented program is a web of objects that collaborate by calling methods on each other. There sometimes can be many dependencies that have to be met in order to call certain objects. To make the complex dependencies be easily testable, mock objects are created in order to “mock” the stages that the object needs to be in, in order to call upon another object.&lt;br /&gt;
&lt;br /&gt;
*Often times in programming, only the changes in state of an object are tested. This would be acceptable only if there was one object. However, many real world applications contain hundreds upon hundreds of different objects. Mock objects have changed the focus of test from thinking about the changes in state of an object to thinking about its interactions with other objects.&lt;br /&gt;
&lt;br /&gt;
==='''Different Types'''===&lt;br /&gt;
&lt;br /&gt;
====Proxy====&lt;br /&gt;
A proxy object is an object that is used to take the place of a real object. This is the original concept for all mock frameworks. In the case of mock objects, a proxy object is used to imitate the real object your code is dependent on. The proxy object is created with the mocking framework, and then set it on the object using either a setter or constructor. One has to be able to set the dependency up through an external means. This is one of the reasons Dependency Injection frameworks like Java Spring have increase in popularity because they allow the ability to inject the proxy objects without modifying code.&lt;br /&gt;
&lt;br /&gt;
====Class Remapping====&lt;br /&gt;
The second form of mocking is to remap the class file in the class loader. The concept is relatively new and is provided by the new java.lang.Instrument class. The basic idea is that the framework tells the class loader to remap the reference to another class file it will load which will be the mocked class. This allows one to be able to mock objects that are created by using the new operator much like other Object Oriented languages. Although this approach provides more functionality than the proxy object approach, it is much more complex and harder to write and fully understand.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Comparison of Different Systems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''EasyMock'''===&lt;br /&gt;
*EasyMock has been the first dynamic Mock Object generator, relieving users of hand-writing Mock Objects, or generating code for them.&lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Supports re-factoring-safe Mock Objects&lt;br /&gt;
*Ability to return values and exceptions.&lt;br /&gt;
*Method order checking&lt;br /&gt;
http://easymock.org/&lt;br /&gt;
&lt;br /&gt;
==='''MOQ'''===&lt;br /&gt;
*Moq is the only mocking library for .NET developed from scratch to take full advantage of .NET 3.5 and C# 3.0 features.&lt;br /&gt;
*Supports mocking interfaces as well as classes. &lt;br /&gt;
*Supports the overriding of expectations where the test can set default expectations in a fixture setup, and override as needed on certain tests&lt;br /&gt;
*Intercept and raise events on mocks&lt;br /&gt;
http://code.google.com/p/moq/.&lt;br /&gt;
&lt;br /&gt;
==='''NMock'''===&lt;br /&gt;
*NMock is a dynamic mock object library for .NET. &lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Allows expectations to be defined and fails the test if any expectations are violated&lt;br /&gt;
*Expectations are specified beforehand and verified on the fly as the code under test is being executed, rather than afterward using assertions&lt;br /&gt;
*Implementations of interfaces are generate on the fly at runtime&lt;br /&gt;
http://www.nmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Rhino Mocks'''===&lt;br /&gt;
*Only supports mocks of interfaces, delegates and classes, including those with parametrized constructors.&lt;br /&gt;
*Expectations on the called methods by using strongly typed mocks instead of strings.&lt;br /&gt;
*Recursive mocking&lt;br /&gt;
http://ayende.com/projects/rhino-mocks.aspx&lt;br /&gt;
&lt;br /&gt;
==='''jMock'''===&lt;br /&gt;
*Forces test to be explicit about the argument values that will be passed to the expected methods&lt;br /&gt;
*Ability to write custom stubs, constraints, and Invocation Matchers&lt;br /&gt;
*Works well with the auto completion and refactoring features of your IDE&lt;br /&gt;
http://www.jmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Mocha'''===&lt;br /&gt;
*Similar to jMock only for Ruby &lt;br /&gt;
*Supports testing frameworks: Test::Unit, RSpec, test/spec, expectations, Dust, MiniTest and JtestR.&lt;br /&gt;
http://mocha.rubyforge.org/&lt;br /&gt;
&lt;br /&gt;
==='''Test::MockObject'''===&lt;br /&gt;
*Similar to jMock only for Perl&lt;br /&gt;
*Simple testing techniques&lt;br /&gt;
http://search.cpan.org/dist/Test-MockObject/lib/Test/MockObject.pm&lt;br /&gt;
&lt;br /&gt;
==='''JMockit'''===&lt;br /&gt;
&lt;br /&gt;
*Simpler and more succinct APIs for writing tests with behavior verification or state verification&lt;br /&gt;
*Provides other tools for supporting the creation of large test suites&lt;br /&gt;
*Uses class remapping instead of the original proxy dependencies&lt;br /&gt;
https://jmockit.dev.java.net/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
A mock object framework can make sure that the method under test, when executed, will in fact call certain functions on the mock object  and that the method under test will react in an appropriate way to whatever the mock objects do. Most parts of a software system do not work in isolation, but collaborate with other parts to get their job done. Writing tests provides a framework to think about functionality, Mock Objects provides a framework for making assertions about those relationships and for simulating responses. Mock Objects also allows programmers to make their tests only as precise as they need to be.&lt;br /&gt;
&lt;br /&gt;
The different frameworks provide a myriad of options for software developers to produce the correct mock tests for their software. The more complex the system, the more important it is when selecting the mock framework. Support for the framework is essential as well. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
1. [http://www.sizovpoint.com/2009/03/java-mock-frameworks-comparison.html Java Mock Framework Comparisons]&lt;br /&gt;
&lt;br /&gt;
2. [http://msdn.microsoft.com/en-us/magazine/dd882516.aspx Using Mocks And Tests To Design Role-Based Objects]&lt;br /&gt;
&lt;br /&gt;
3. [http://en.wikipedia.org/wiki/Mock_object Wikipedia - Mock object]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19143</id>
		<title>CSC/ECE 517 Fall 2009/wiki1a 2 sn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19143"/>
		<updated>2009-09-13T18:54:01Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: /* Definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Comparison of Mock Frameworks ==&lt;br /&gt;
'''NOTE:''' THIS SECTION WILL BE REMOVED FOR FINAL VERSION&lt;br /&gt;
&lt;br /&gt;
Assignment:&lt;br /&gt;
Mock objects and mock frameworks.  When performing tests, it's convenient to have the objects be in a particular configuration, so that boundary cases can be tested.  Setting up the objects can sometimes be complicated.  The Wikipedia article for mock objects lists several, but does not compare them.  Compare different systems for mock objects, and mock frameworks (which are used to set up mock objects).&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. A computer programmer typically creates a mock object to test the behavior of some other object, in much the same way that a car designer uses a crash test dummy to simulate the dynamic behavior of a human in vehicle impacts. [FROM http://en.wikipedia.org/wiki/Mock_object ]&lt;br /&gt;
&lt;br /&gt;
Mock frameworks are the environments that are available to create these mock objects and mock tests. &lt;br /&gt;
There are many different types of frameworks for different platforms. They are a set of programmable APIs that allow creation of mock and stub objects in relative easy fashion. Mock frameworks save the developer from the need to write repetitive code to test or simulate object interactions.&lt;br /&gt;
&lt;br /&gt;
== Concepts ==&lt;br /&gt;
&lt;br /&gt;
==='''Why Mock?'''===&lt;br /&gt;
&lt;br /&gt;
*The concept behind mock objects is that there is a need to create an object that will take the place of the real object. This mock object will expect a certain method to be called with certain parameters and when that happens, it will return an expected result. When writing units tests for a class that would normally use the real object, we can instead supply it with a mock object. This allows us a new level of flexibility in testing.&lt;br /&gt;
&lt;br /&gt;
*Ease of modifying the mock object during separate tests to get it to get it to return a range of different data. Test can pass in valid, invalid, and extreme ranges to test how the code calling it handles such situations.&lt;br /&gt;
&lt;br /&gt;
*Simulation of failures, such as the inability to connect to a database, to test the failure mode of classes.&lt;br /&gt;
&lt;br /&gt;
*Encourages better structured tests and, more importantly, improved domain code by preserving encapsulation, reducing dependencies and clarifying the interactions between classes. A running Object-Oriented program is a web of objects that collaborate by calling methods on each other. There sometimes can be many dependencies that have to be met in order to call certain objects. To make the complex dependencies be easily testable, mock objects are created in order to “mock” the stages that the object needs to be in, in order to call upon another object.&lt;br /&gt;
&lt;br /&gt;
*Often times in programming, only the changes in state of an object are tested. This would be acceptable only if there was one object. However, many real world applications contain hundreds upon hundreds of different objects. Mock objects have changed the focus of test from thinking about the changes in state of an object to thinking about its interactions with other objects.&lt;br /&gt;
&lt;br /&gt;
==='''Different Types'''===&lt;br /&gt;
&lt;br /&gt;
====Proxy====&lt;br /&gt;
A proxy object is an object that is used to take the place of a real object. This is the original concept for all mock frameworks. In the case of mock objects, a proxy object is used to imitate the real object your code is dependent on. The proxy object is created with the mocking framework, and then set it on the object using either a setter or constructor. One has to be able to set the dependency up through an external means. This is one of the reasons Dependency Injection frameworks like Java Spring have increase in popularity because they allow the ability to inject the proxy objects without modifying code.&lt;br /&gt;
&lt;br /&gt;
====Class Remapping====&lt;br /&gt;
The second form of mocking is to remap the class file in the class loader. The concept is relatively new and is provided by the new java.lang.Instrument class. The basic idea is that the framework tells the class loader to remap the reference to another class file it will load which will be the mocked class. This allows one to be able to mock objects that are created by using the new operator much like other Object Oriented languages. Although this approach provides more functionality than the proxy object approach, it is much more complex and harder to write and fully understand.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Comparison of Different Systems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''EasyMock'''===&lt;br /&gt;
*EasyMock has been the first dynamic Mock Object generator, relieving users of hand-writing Mock Objects, or generating code for them.&lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Supports re-factoring-safe Mock Objects&lt;br /&gt;
*Ability to return values and exceptions.&lt;br /&gt;
*Method order checking&lt;br /&gt;
http://easymock.org/&lt;br /&gt;
&lt;br /&gt;
==='''MOQ'''===&lt;br /&gt;
*Moq is the only mocking library for .NET developed from scratch to take full advantage of .NET 3.5 and C# 3.0 features.&lt;br /&gt;
*Supports mocking interfaces as well as classes. &lt;br /&gt;
*Supports the overriding of expectations where the test can set default expectations in a fixture setup, and override as needed on certain tests&lt;br /&gt;
*Intercept and raise events on mocks&lt;br /&gt;
http://code.google.com/p/moq/.&lt;br /&gt;
&lt;br /&gt;
==='''NMock'''===&lt;br /&gt;
*NMock is a dynamic mock object library for .NET. &lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Allows expectations to be defined and fails the test if any expectations are violated&lt;br /&gt;
*Expectations are specified beforehand and verified on the fly as the code under test is being executed, rather than afterward using assertions&lt;br /&gt;
*Implementations of interfaces are generate on the fly at runtime&lt;br /&gt;
http://www.nmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Rhino Mocks'''===&lt;br /&gt;
*Only supports mocks of interfaces, delegates and classes, including those with parametrized constructors.&lt;br /&gt;
*Expectations on the called methods by using strongly typed mocks instead of strings.&lt;br /&gt;
*Recursive mocking&lt;br /&gt;
http://ayende.com/projects/rhino-mocks.aspx&lt;br /&gt;
&lt;br /&gt;
==='''jMock'''===&lt;br /&gt;
*Forces test to be explicit about the argument values that will be passed to the expected methods&lt;br /&gt;
*Ability to write custom stubs, constraints, and Invocation Matchers&lt;br /&gt;
*Works well with the auto completion and refactoring features of your IDE&lt;br /&gt;
http://www.jmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Mocha'''===&lt;br /&gt;
*Similar to jMock only for Ruby &lt;br /&gt;
*Supports testing frameworks: Test::Unit, RSpec, test/spec, expectations, Dust, MiniTest and JtestR.&lt;br /&gt;
http://mocha.rubyforge.org/&lt;br /&gt;
&lt;br /&gt;
==='''Test::MockObject'''===&lt;br /&gt;
*Similar to jMock only for Perl&lt;br /&gt;
*Simple testing techniques&lt;br /&gt;
http://search.cpan.org/dist/Test-MockObject/lib/Test/MockObject.pm&lt;br /&gt;
&lt;br /&gt;
==='''JMockit'''===&lt;br /&gt;
&lt;br /&gt;
*Simpler and more succinct APIs for writing tests with behavior verification or state verification&lt;br /&gt;
*Provides other tools for supporting the creation of large test suites&lt;br /&gt;
*Uses class remapping instead of the original proxy dependencies&lt;br /&gt;
https://jmockit.dev.java.net/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
A mock object framework can make sure that the method under test, when executed, will in fact call certain functions on the mock object  and that the method under test will react in an appropriate way to whatever the mock objects do. Most parts of a software system do not work in isolation, but collaborate with other parts to get their job done. Writing tests provides a framework to think about functionality, Mock Objects provides a framework for making assertions about those relationships and for simulating responses. Mock Objects also allows programmers to make their tests only as precise as they need to be.&lt;br /&gt;
&lt;br /&gt;
The different frameworks provide a myriad of options for software developers to produce the correct mock tests for their software. The more complex the system, the more important it is when selecting the mock framework. Support for the framework is essential as well. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
1. [http://www.sizovpoint.com/2009/03/java-mock-frameworks-comparison.html Java Mock Framework Comparisons]&lt;br /&gt;
&lt;br /&gt;
2. [http://msdn.microsoft.com/en-us/magazine/dd882516.aspx Using Mocks And Tests To Design Role-Based Objects]&lt;br /&gt;
&lt;br /&gt;
3. [http://en.wikipedia.org/wiki/Mock_object Wikipedia - Mock object]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki_1a_9b_SJ&amp;diff=19142</id>
		<title>CSC/ECE 517 Fall 2009/wiki 1a 9b SJ</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki_1a_9b_SJ&amp;diff=19142"/>
		<updated>2009-09-13T18:49:21Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== What is Code Refactoring ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to the famous book &amp;quot;Refactoring: Improving the Design of Existing Code &amp;quot; by Martin Fowler: Refactoring is the process of applying behavior-preserving transformations &lt;br /&gt;
to a program with the objective of improving the program’s design. Intuitively people refer to code refactoring as &amp;quot;cleaning it up.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Motivation of Refactoring ===&lt;br /&gt;
&lt;br /&gt;
Refactoring is very useful for software engineer to maintain the quality of their code in different environment. In fact, no software can be guaranteed to be perfect when it is first developed. &lt;br /&gt;
Usually when the source code is applied to different customer needs, we want to improve the inner-structure without modify the external behavior. The ability to refactor your code takes &lt;br /&gt;
the pressure off the design phase of software development. Refactoring gives you the ability to change the design of the code at a later stage. This means that you don’t have to get the&lt;br /&gt;
design absolutely right before you write any code. You can get a rough design worked out, code it up and then if (when) you spot a better design you can refactor your code towards the &lt;br /&gt;
better design.&lt;br /&gt;
&lt;br /&gt;
=== List of Common Refactorings ===&lt;br /&gt;
&lt;br /&gt;
In the following we list some popular refactoring to specify how refactoring transform the code. For more detail information, the reader please refer to the section 2.1.2 of the &lt;br /&gt;
thesis of Thomas Corbat[1]. [1] provide Ruby example for each refactoring this list.   &lt;br /&gt;
  &lt;br /&gt;
{|&lt;br /&gt;
| 1. Merge Class Parts &lt;br /&gt;
|-&lt;br /&gt;
|	2. Convert Local Variable to Field &lt;br /&gt;
|-&lt;br /&gt;
|	3. Encapsulate Field &lt;br /&gt;
|-&lt;br /&gt;
|	4. Extract Method &lt;br /&gt;
|-&lt;br /&gt;
|	5. Inline Class &lt;br /&gt;
|-&lt;br /&gt;
|	6. Inline Method &lt;br /&gt;
|-&lt;br /&gt;
|	7. Move Field &lt;br /&gt;
|-&lt;br /&gt;
|	8. Move Method &lt;br /&gt;
|-&lt;br /&gt;
|	9. Rename Class &lt;br /&gt;
|-&lt;br /&gt;
|	10. Rename Field &lt;br /&gt;
|-&lt;br /&gt;
|	11. Rename Local Variable &lt;br /&gt;
|-&lt;br /&gt;
|	12. Rename Method &lt;br /&gt;
|-&lt;br /&gt;
|	13. Replace Temporary Variable with Query &lt;br /&gt;
|-&lt;br /&gt;
|	14. Split Temporary Variable &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Ruby Example of Refactoring ===&lt;br /&gt;
&lt;br /&gt;
before rename:&lt;br /&gt;
&lt;br /&gt;
 def badRenameMethod&lt;br /&gt;
    puts(&amp;quot;Hello World&amp;quot;);&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
after rename:&lt;br /&gt;
&lt;br /&gt;
 def hello&lt;br /&gt;
    puts(&amp;quot;Hello World&amp;quot;);&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
before encapsulation:&lt;br /&gt;
 &lt;br /&gt;
 class SomeClass&lt;br /&gt;
    def initialize&lt;br /&gt;
        @field = 0;&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
after encapsulation:&lt;br /&gt;
&lt;br /&gt;
 class SomeClass                &lt;br /&gt;
    def initialize&lt;br /&gt;
        @field = 0;&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    def field&lt;br /&gt;
        @field&lt;br /&gt;
    end&lt;br /&gt;
    private :field&lt;br /&gt;
    &lt;br /&gt;
    def field= field&lt;br /&gt;
        @field = field&lt;br /&gt;
    end&lt;br /&gt;
    private :field=&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Java Example of Refactoring ===&lt;br /&gt;
&lt;br /&gt;
before rename:&lt;br /&gt;
&lt;br /&gt;
 public class rename_method&lt;br /&gt;
 {&lt;br /&gt;
    static void badRenameMethod()&lt;br /&gt;
    {&lt;br /&gt;
        System.out.println(&amp;quot;Hello, world!&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
after rename:&lt;br /&gt;
&lt;br /&gt;
 public class rename_method&lt;br /&gt;
 {&lt;br /&gt;
    static void hello()&lt;br /&gt;
    {&lt;br /&gt;
        System.out.println(&amp;quot;Hello, world!&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
before encapsulation:&lt;br /&gt;
&lt;br /&gt;
 public class encap_field&lt;br /&gt;
 {&lt;br /&gt;
    public String field;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
after encapsulation:&lt;br /&gt;
&lt;br /&gt;
 public class encap_field&lt;br /&gt;
 {&lt;br /&gt;
    private int field;&lt;br /&gt;
&lt;br /&gt;
    public void setField(int field)&lt;br /&gt;
    {&lt;br /&gt;
        this.field = field;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public int getField()&lt;br /&gt;
    {&lt;br /&gt;
        return field;&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Refactoring support for Current Ruby IDE ==&lt;br /&gt;
&lt;br /&gt;
This the following table we summary the current ruby IDE and their refactoring support situation. &lt;br /&gt;
{| &lt;br /&gt;
 | Current Ruby IDE || Refactoring Support (Y/N)&lt;br /&gt;
|-&lt;br /&gt;
 | ActiveState Komodo  || N&lt;br /&gt;
 |- &lt;br /&gt;
 | NetBeans || N&lt;br /&gt;
 |-&lt;br /&gt;
 | Arachno Ruby ||  N&lt;br /&gt;
|-&lt;br /&gt;
 | FreeRIDE || N&lt;br /&gt;
|-&lt;br /&gt;
 | Mondrian Ruby IDE || N&lt;br /&gt;
|-&lt;br /&gt;
 | Ruby in Steel || N&lt;br /&gt;
|-&lt;br /&gt;
 | RubyMine || Y&lt;br /&gt;
|-&lt;br /&gt;
 | Eclipse (Aptana) || Y  &lt;br /&gt;
 |}&lt;br /&gt;
&lt;br /&gt;
=== Example of Using Ruby Refactoring Tools in Eclipse ===&lt;br /&gt;
Here the renaming of the method &amp;quot;badRenameMethod&amp;quot; to &amp;quot;Hello&amp;quot; is illustrated for Ruby.  The source code is shown in section 1.3.&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:r00.jpg|thumb|upright|alt= rename step 1]]&lt;br /&gt;
| [[Image:r01.jpg|thumb|upright|alt= rename step 2]]&lt;br /&gt;
| [[Image:r02.jpg|thumb|upright|alt= rename step 3]]&lt;br /&gt;
| [[Image:r03.jpg|thumb|upright|alt= rename step 4]]&lt;br /&gt;
| [[Image:r04.jpg|thumb|upright|alt= rename step 5]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Here the encapsulation of the field &amp;quot;field&amp;quot; is illustrated for Ruby.  The source code is show in section 1.3.&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:r05.jpg|thumb|upright|alt= encapsulation step 1]]&lt;br /&gt;
| [[Image:r06.jpg|thumb|upright|alt= encapsulation step 2]]&lt;br /&gt;
| [[Image:r07.jpg|thumb|upright|alt= encapsulation step 3]]&lt;br /&gt;
| [[Image:r08.jpg|thumb|upright|alt= encapsulation step 4]]&lt;br /&gt;
| [[Image:r09.jpg|thumb|upright|alt= encapsulation step 5]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example of Using Java Refactoring Tools in Eclipse ===&lt;br /&gt;
Here the renaming of the method &amp;quot;badRenameMethod&amp;quot; to &amp;quot;Hello&amp;quot; is illustrated for Java. The source code is show in section 1.4. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[Image:j00.jpg|thumb|upright|alt= rename step 1]]&lt;br /&gt;
| [[Image:j01.jpg|thumb|upright|alt= rename step 2]]&lt;br /&gt;
| [[Image:j02.jpg|thumb|upright|alt= rename step 3]]&lt;br /&gt;
| [[Image:j03.jpg|thumb|upright|alt= rename step 4]]&lt;br /&gt;
| [[Image:j04.jpg|thumb|upright|alt= rename step 5]]&lt;br /&gt;
| [[Image:j05.jpg|thumb|upright|alt= rename step 6]]&lt;br /&gt;
|}&lt;br /&gt;
Here the encapsulation of the field &amp;quot;field&amp;quot; is illustrated for Java. The source code is show in section 1.4.&lt;br /&gt;
 &lt;br /&gt;
{|&lt;br /&gt;
| [[Image:j06.jpg|thumb|upright|alt= encapsulation step 1]]&lt;br /&gt;
| [[Image:j07.jpg|thumb|upright|alt= encapsulation step 2]]&lt;br /&gt;
| [[Image:j08.jpg|thumb|upright|alt= encapsulation step 3]]&lt;br /&gt;
| [[Image:j09.jpg|thumb|upright|alt= encapsulation step 4]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Comparison of Ruby and Java Refactoring Tools ==&lt;br /&gt;
Comprehensiveness comparison:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|1. Refactoring Options for Java in Eclipse  ||||  2. Refactoring Options in Eclipse for Ruby&lt;br /&gt;
|-&lt;br /&gt;
|Rename   || || Rename&lt;br /&gt;
|-&lt;br /&gt;
|Move || || Move&lt;br /&gt;
|-&lt;br /&gt;
|Change Method Signature || || Merge Class Parts in File&lt;br /&gt;
|-&lt;br /&gt;
|Extract Local Variable || || Pull Up&lt;br /&gt;
|-&lt;br /&gt;
|Extract Constant || || Pull Down&lt;br /&gt;
|-&lt;br /&gt;
|Inline || || Merge With External Class Parts&lt;br /&gt;
|-&lt;br /&gt;
|Convert Anonymous Class to Nested || || Split Local Variable&lt;br /&gt;
|-&lt;br /&gt;
|Convert Member to Top Level || || Merge With External Class Parts&lt;br /&gt;
|-&lt;br /&gt;
|Convert Local Variable to Field || || Inline&lt;br /&gt;
|-&lt;br /&gt;
|Extract Super Class || || Extract Constant&lt;br /&gt;
|-&lt;br /&gt;
|Extract Interface || || Encapsulate Field&lt;br /&gt;
|-&lt;br /&gt;
|Extract Class || || Convert Local Variable to Field&lt;br /&gt;
|-&lt;br /&gt;
|Use Supertype where possible&lt;br /&gt;
|-&lt;br /&gt;
|Pull Up &lt;br /&gt;
|-&lt;br /&gt;
|Pull Down &lt;br /&gt;
|-&lt;br /&gt;
|Introduce Parameter Object&lt;br /&gt;
|-&lt;br /&gt;
|Introduce Indirection&lt;br /&gt;
|-&lt;br /&gt;
|Introduce Factory&lt;br /&gt;
|-&lt;br /&gt;
|Introduce Parameter&lt;br /&gt;
|-&lt;br /&gt;
|Encapsulate Field&lt;br /&gt;
|-&lt;br /&gt;
|Generalize Declared Type&lt;br /&gt;
|-&lt;br /&gt;
|Infer Generic Type Arguments&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The refactoring options for Ruby and Java cover all the basic refactorings.  The differences in the number of options mainly come from the difference in the two languages. &lt;br /&gt;
 Ruby is a dynamically typed language, has unbounded polymorphism, and all classes are open to extension.  On the other hand, Java is a statically typed language, &lt;br /&gt;
polymorphism is mainly implemented via interfaces and inheritance, and classes cannot be extended at runtime.  The given examples (in section 1.3, 1.4)&lt;br /&gt;
 illustrate the ease of use of the refactoring tools for both Ruby and Java and how well these tools are integrated into the Eclipse IDE.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[1] Thomas Corbat, Lukas Felber, Mirko Stocker&lt;br /&gt;
Refactoring Support for the Eclipse Ruby Development Tools, Diploma Thesis, HSR University of Applied Sciences Rapperswil Institute for Software.&lt;br /&gt;
&lt;br /&gt;
[2] code refactoring wiki, http://en.wikipedia.org/wiki/Code_refactoring.&lt;br /&gt;
&lt;br /&gt;
[3] the first workshop on refactoring, https://netfiles.uiuc.edu/dig/RefactoringWorkshop&lt;br /&gt;
&lt;br /&gt;
[4] refactoring tutorial on ruby on rail, http://www.good-tutorials.com/tutorials/ruby-on-rails/refactoring&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19095</id>
		<title>CSC/ECE 517 Fall 2009/wiki1a 2 sn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1a_2_sn&amp;diff=19095"/>
		<updated>2009-09-12T15:29:59Z</updated>

		<summary type="html">&lt;p&gt;Cjjacks2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Comparison of Mock Frameworks ==&lt;br /&gt;
'''NOTE:''' THIS SECTION WILL BE REMOVED FOR FINAL VERSION&lt;br /&gt;
&lt;br /&gt;
Assignment:&lt;br /&gt;
Mock objects and mock frameworks.  When performing tests, it's convenient to have the objects be in a particular configuration, so that boundary cases can be tested.  Setting up the objects can sometimes be complicated.  The Wikipedia article for mock objects lists several, but does not compare them.  Compare different systems for mock objects, and mock frameworks (which are used to set up mock objects).&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. A computer programmer typically creates a mock object to test the behavior of some other object, in much the same way that a car designer uses a crash test dummy to simulate the dynamic behavior of a human in vehicle impacts. [FROM http://en.wikipedia.org/wiki/Mock_object ]&lt;br /&gt;
&lt;br /&gt;
Mock Frameworks are the environments that are available to create these mock objects and mock tests. &lt;br /&gt;
There are many different types of frameworks for different platforms. They are a set of programmable APIs that allow creation of mock and stub objects in relative easy fashion. Mock frameworks save the developer from the need to write repetitive code to test or simulate object interactions.  &lt;br /&gt;
&lt;br /&gt;
== Concepts ==&lt;br /&gt;
&lt;br /&gt;
==='''Why Mock?'''===&lt;br /&gt;
&lt;br /&gt;
*The concept behind mock objects is that there is a need to create an object that will take the place of the real object. This mock object will expect a certain method to be called with certain parameters and when that happens, it will return an expected result. When writing units tests for a class that would normally use the real object, we can instead supply it with a mock object. This allows us a new level of flexibility in testing.&lt;br /&gt;
&lt;br /&gt;
*Ease of modifying the mock object during separate tests to get it to get it to return a range of different data. Test can pass in valid, invalid, and extreme ranges to test how the code calling it handles such situations.&lt;br /&gt;
&lt;br /&gt;
*Simulation of failures, such as the inability to connect to a database, to test the failure mode of classes.&lt;br /&gt;
&lt;br /&gt;
*Encourages better structured tests and, more importantly, improved domain code by preserving encapsulation, reducing dependencies and clarifying the interactions between classes. A running Object-Oriented program is a web of objects that collaborate by calling methods on each other. There sometimes can be many dependencies that have to be met in order to call certain objects. To make the complex dependencies be easily testable, mock objects are created in order to “mock” the stages that the object needs to be in, in order to call upon another object.&lt;br /&gt;
&lt;br /&gt;
*Often times in programming, only the changes in state of an object are tested. This would be acceptable only if there was one object. However, many real world applications contain hundreds upon hundreds of different objects. Mock objects have changed the focus of test from thinking about the changes in state of an object to thinking about its interactions with other objects.&lt;br /&gt;
&lt;br /&gt;
==='''Different Types'''===&lt;br /&gt;
&lt;br /&gt;
====Proxy====&lt;br /&gt;
A proxy object is an object that is used to take the place of a real object. This is the original concept for all mock frameworks. In the case of mock objects, a proxy object is used to imitate the real object your code is dependent on. The proxy object is created with the mocking framework, and then set it on the object using either a setter or constructor. One has to be able to set the dependency up through an external means. This is one of the reasons Dependency Injection frameworks like Java Spring have increase in popularity because they allow the ability to inject the proxy objects without modifying code.&lt;br /&gt;
&lt;br /&gt;
====Class Remapping====&lt;br /&gt;
The second form of mocking is to remap the class file in the class loader. The concept is relatively new and is provided by the new java.lang.Instrument class. The basic idea is that the framework tells the class loader to remap the reference to another class file it will load which will be the mocked class. This allows one to be able to mock objects that are created by using the new operator much like other Object Oriented languages. Although this approach provides more functionality than the proxy object approach, it is much more complex and harder to write and fully understand.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Comparison of Different Systems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''EasyMock'''===&lt;br /&gt;
*EasyMock has been the first dynamic Mock Object generator, relieving users of hand-writing Mock Objects, or generating code for them.&lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Supports re-factoring-safe Mock Objects&lt;br /&gt;
*Ability to return values and exceptions.&lt;br /&gt;
*Method order checking&lt;br /&gt;
http://easymock.org/&lt;br /&gt;
&lt;br /&gt;
==='''MOQ'''===&lt;br /&gt;
*Moq is the only mocking library for .NET developed from scratch to take full advantage of .NET 3.5 and C# 3.0 features.&lt;br /&gt;
*Supports mocking interfaces as well as classes. &lt;br /&gt;
*Supports the overriding of expectations where the test can set default expectations in a fixture setup, and override as needed on certain tests&lt;br /&gt;
*Intercept and raise events on mocks&lt;br /&gt;
http://code.google.com/p/moq/.&lt;br /&gt;
&lt;br /&gt;
==='''NMock'''===&lt;br /&gt;
*NMock is a dynamic mock object library for .NET. &lt;br /&gt;
*Dynamic creation of Mock Objects&lt;br /&gt;
*Allows expectations to be defined and fails the test if any expectations are violated&lt;br /&gt;
*Expectations are specified beforehand and verified on the fly as the code under test is being executed, rather than afterward using assertions&lt;br /&gt;
*Implementations of interfaces are generate on the fly at runtime&lt;br /&gt;
http://www.nmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Rhino Mocks'''===&lt;br /&gt;
*Only supports mocks of interfaces, delegates and classes, including those with parametrized constructors.&lt;br /&gt;
*Expectations on the called methods by using strongly typed mocks instead of strings.&lt;br /&gt;
*Recursive mocking&lt;br /&gt;
http://ayende.com/projects/rhino-mocks.aspx&lt;br /&gt;
&lt;br /&gt;
==='''jMock'''===&lt;br /&gt;
*Forces test to be explicit about the argument values that will be passed to the expected methods&lt;br /&gt;
*Ability to write custom stubs, constraints, and Invocation Matchers&lt;br /&gt;
*Works well with the auto completion and refactoring features of your IDE&lt;br /&gt;
http://www.jmock.org/index.html&lt;br /&gt;
&lt;br /&gt;
==='''Mocha'''===&lt;br /&gt;
*Similar to jMock only for Ruby &lt;br /&gt;
*Supports testing frameworks: Test::Unit, RSpec, test/spec, expectations, Dust, MiniTest and JtestR.&lt;br /&gt;
http://mocha.rubyforge.org/&lt;br /&gt;
&lt;br /&gt;
==='''Test::MockObject'''===&lt;br /&gt;
*Similar to jMock only for Perl&lt;br /&gt;
*Simple testing techniques&lt;br /&gt;
http://search.cpan.org/dist/Test-MockObject/lib/Test/MockObject.pm&lt;br /&gt;
&lt;br /&gt;
==='''JMockit'''===&lt;br /&gt;
&lt;br /&gt;
*Simpler and more succinct APIs for writing tests with behavior verification or state verification&lt;br /&gt;
*Provides other tools for supporting the creation of large test suites&lt;br /&gt;
*Uses class remapping instead of the original proxy dependencies&lt;br /&gt;
https://jmockit.dev.java.net/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
A mock object framework can make sure that the method under test, when executed, will in fact call certain functions on the mock object  and that the method under test will react in an appropriate way to whatever the mock objects do. Most parts of a software system do not work in isolation, but collaborate with other parts to get their job done. Writing tests provides a framework to think about functionality, Mock Objects provides a framework for making assertions about those relationships and for simulating responses. Mock Objects also allows programmers to make their tests only as precise as they need to be.&lt;br /&gt;
&lt;br /&gt;
The different frameworks provide a myriad of options for software developers to produce the correct mock tests for their software. The more complex the system, the more important it is when selecting the mock framework. Support for the framework is essential as well. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
1. [http://www.sizovpoint.com/2009/03/java-mock-frameworks-comparison.html Java Mock Framework Comparisons]&lt;br /&gt;
&lt;br /&gt;
2. [http://msdn.microsoft.com/en-us/magazine/dd882516.aspx Using Mocks And Tests To Design Role-Based Objects]&lt;br /&gt;
&lt;br /&gt;
3. [http://en.wikipedia.org/wiki/Mock_object Wikipedia - Mock object]&lt;/div&gt;</summary>
		<author><name>Cjjacks2</name></author>
	</entry>
</feed>