In: Computer Science
Program Slicing Assignment
1- Choose a program you’d like to analyze. Explain what the program’s purpose is and how many lines of code it has.
2- Browse the tools necessary for slicing and install if you haven’t already done so.
If there is a problem with the tool, and you would not like to use it, explain:
What the tool is used for, and why wouldn’t use it.
3- demonstrate static, dynamic, forward, and backward slicing using a slicing criterion.
In a documentation, submit examples and descriptions of each static and dynamic slicing. Submit descriptions and examples of forward and backward slicing.
3- demonstrate static, dynamic, forward, and backward slicing using a slicing criterion.
As it is not mentioned which question needs to be done, I am doing the first two questions of this assignment
(A) I would like to analyze a program which helps to find the factorial of a number
Purpose -: The purpose of this program is to find the factorial of the user inputted number using recursive function.
Number of lines in the code is as follows -:
14 physical lines of code excluding whitespace, including logical lines of codes
PROGRAM -:
class Test {
static int factorial(int n)
{
if(n == 0)
return 1;
return(n* factorial(n-1))
}
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
System.out.println( "Factorial of " + num + " is " + factorial(num));
}
}
(B) A tool that I browsed and installed for the purpose of program slicing is CodeSurfer.
CodeSurfer is a tool that gives eases reading and understanding of code and also provides a variety of effects of the code and its effect.
There is one problem with this tool is that 100k lines of code is the upper bound. No integration with eclipse, visual studio, etc.