In software applications, program slicing is a method of identifying the core elements of a software program and gently extracting them from the more complicated code that allows the program to function. This is especially important to software engineering efforts, as it allows the software engineer to find the way through complicated strings of code in order to access the source code that actually drives the application. Being able to extract these subprograms and view the source code makes it possible to identify a wide range of potential bugs and thus make the software run with more efficiency.
It is not unusual for code to be intentionally complicated. One of the main reasons for this action is that the more complicated portions of the code help to protect the source code from corruption by viruses and hacking attempts. Usually, a programmer will add a great deal of extra code that essentially makes it necessary to go through a number of extra steps to accomplish what could be managed by the source code with only a few steps. While this is a desirable state from the perspective of protecting the software from possible corruption, there are situations where there is a need to get to the source code. That is where program slicing comes into play.
There are two basic approaches or dimensions to program slicing. The semantic dimension focuses on the elements of the code string that are necessary and thus will be retained. Both static and dynamic functions are identified and preserved by making use of specific methods of slicing that leave behind the essential elements but remove much of the code inserted as part of the masking process. With semantic program slicing, the engineer has a fair amount of discretion in deciding what, if any, of the extra code actually remains.
Syntactic program slicing does not provide the engineer with the same amount of options. With this approach, anything that is not essential to the core function of the code is removed. If a string is found to serve no real purpose and does not have any impact on the semantics of interest found in the code, it goes. This approach helps to preserve the original syntax of the program without any extra frills.
A second and increasingly common use of syntactic program slicing is known as amorphous program slicing. With this approach, the goal is to make it possible for the slice to continue working with any syntactic function that helps to maintain the semantic constraints that the engineer wishes to preserve in the code.