Slicing or program slicing is a technique used in software testing which takes a slice or a group of program statements in the program for testing particular test conditions or cases and that may affect a value at a particular point of interest. It can also be used for the purpose of debugging in order to find the bugs more easily and quickly.
Slicing techniques were originally defined by Mark Weiser and they were only static in nature at that time. Afterwards, Bogdan Korel and Janusz Laski introduced dynamic slicing, which can work for a particular execution of the program.
It is of 2 types: static slicing and dynamic slicing, these are explained as following below:
1. Static slicing:
- A static slice of a program contains all statements that may affect the value of a variable at any point for any arbitrary execution of the program.
- Static slices are generally larger.
- It considers every possible execution of the program.
2. Dynamic slicing:
- A dynamic slice of a program contains all the statements that actually affect the value of a variable at any point for a particular execution of the program.
- Dynamic slices are generally smaller.
- Considers only a particular execution of the program.
Let us see an example by the given code snippet:
Static slice for the variable sum:
Dynamic slice for the variable sum when n = 22;
As it can be observed in the above example that static slice takes all the possible execution (in this case it is 2) of the program which may affect the value of the variable sum. Whereas in case of dynamic slicing, it considers only a particular execution (when n = 22) of the program which may affect the value of the variable sum.
Hence, dynamic slice is always smaller than a static slice.
- Software Engineering | Project size estimation techniques
- Types of Software Testing
- Software Testing | Basics
- Software Engineering | Architectural Design
- Software Engineering | Halstead’s Software Metrics
- Beta Testing | Software Testing
- Software Engineering | Debugging Approaches
- Pairwise Software Testing
- Software Engineering | COCOMO Model
- Software Engineering | Classification of Software Requirements
- Software Engineering | Classical Waterfall Model
- Software Engineering | Iterative Waterfall Model
- Software Engineering | Spiral Model
- Software Engineering | Requirements Engineering Process
- Software Engineering | Requirements Elicitation
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : ashwani prasad