Download presentation
Presentation is loading. Please wait.
Published byGloria Hopkins Modified over 9 years ago
1
SwE 455 Program Slicing
2
Our Goals Debug your thousands lines of code easily by reducing the complexity of the program Write a robust program before testing your code Save your regression testing time by limiting the tests to only those that exercise the changed code
3
Approach “Break your code into smaller pieces”
4
Program Slicing What is it? - A well-known program analysis and transformation technique that uses program statement dependence information to identify parts of a program that influence or are influenced by an initial set of program points of interest which is called the slice criteria - Introduced by Mark Weiser in his Ph.D. thesis (1979)
5
slicing criterion is provided by the user Source program Resulting slice Slice Slicing Criterion Slicing Criterion indirectly relevant indirectly relevant Program Slicing (cont’d)
6
Variants of Program Slicing Many different variants of program slicing exist 1.Static Slicing 2.Backward Slicing 3.Forward Slicing 4.Dynamic Slicing 5.Conditional Slicing 6.Chopping Also Many Different tools, however – Most program slicing tools are written for C but there are also some for C++ and Java – Most of these have problems with dynamic binding, inheritance, polymorphism and performance
7
Backward Slice Example public class SimpleExample { static int add(int a, int b){ return(a+b); } public static void main(final String[] arg){ int i = 1; int sum = 0; while (i < 11) { sum = add(sum, i); i = add(i, 1); } System.out.println("sum = " + sum); System.out.println("i = " + i); } Slicing Criterion Slicing Criterion
8
Forward Slice Example public class SimpleExample { static int add(int a, int b){ return(a+b); } public static void main(final String[] arg){ int i = 1; int sum = 0; while (i < 11) { sum = add(sum, i); i = add(i, 1); } System.out.println("sum = " + sum); System.out.println("i = " + i); } Slicing Criterion Slicing Criterion
9
Why is It Useful? Program slicing is useful in many different states of the software development lifecycle – Debugging: Slicing visualizes control and data dependencies It highlights statements influencing the slice – Testing: Tests may be decomposed and test-work gets faster and more efficient – Software quality assurance Safety critical code can be isolated and functions can be implemented redundant and in functional diversity manner – Software measurement, Maintenance,….
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.