Presentation is loading. Please wait.

Presentation is loading. Please wait.

Csci 565 Spring 2009.  Originally proposed by [Weiser 88]and [Gallagher 91] in software maintenance  Useful for  Software Debugging  Software Maintenance.

Similar presentations

Presentation on theme: "Csci 565 Spring 2009.  Originally proposed by [Weiser 88]and [Gallagher 91] in software maintenance  Useful for  Software Debugging  Software Maintenance."— Presentation transcript:

1 Csci 565 Spring 2009

2  Originally proposed by [Weiser 88]and [Gallagher 91] in software maintenance  Useful for  Software Debugging  Software Maintenance  Program understanding  Quantification of functional cohesion

3  A complementary method of program decomposition that applied after the program is written/designed  Purpose  Debugging (subset of behavior is fixed)  Maintenance (subset of program is improved)  Works on actual program  Specify program behaviors using a sets of variables at some set of statements

4  Slicing criterion for a program specifies a windows for observing its behavior  Where a window ▪ specified as a statement and a set of variables ▪ Allows the observations of values of the specified variables before execution of particular statement ▪ E.g., S(x, 24) (i.e., value of x at line 24)

5  The Commission Problem Statement Locks cost $45.00, stocks cost $30.00, and barrels cost $25.00  Rifle salesperson in the Arizona Territory sold rifle locks, stocks, and barrels made by a gunsmith in Missouri. Locks cost $45.00, stocks cost $30.00, and barrels cost $25.00. Salespersons had to sell at least one complete rifle per month, and production limits are such that the most one salesperson could sell in one month is 70 locks, 80 stocks, 90 barrels. Each rifle salesperson sent a telegram to the Missouri company with the total order for each town s/he visits; salespersons visit at least one town per month, but travel difficulties made ten towns the upper limit. At the end of each month, the company computed commission as follows: ▪ 10% on sales up to $1000 ▪ 15% on the next $800 ▪ 20% on any sales in excess of $1800.  The company had four salespersons. The telegram from each salesperson were sorted into piles (by person) and at the end of each month a data file is prepared, containing the salesperson's name, followed by one line for each telegram order, showing the number of locks, stocks, and barrels in that order. At the end of the sales data lines, there is an entry of “-1” in the position where the number of locks would be to signal the end of input for that salesperson. The program produces a monthly sales report that gives the salesperson’s name, the total number of locks, stocks, and barrels sold, the salesperson's total dollar sales, and finally his/her commission.




9 Lock has a predicate usage

10  Slice-based Testing technique  divide a program into components (or slices)  A program slice?  Refers to a set of program statements that may affect the computation of variable v at statement s




14  Given a program P, a program graph G(P) in which statements are numbered, and a set V of variables in P, the slice on the variable set V at statement n, S(V,n) prior to ncontribute to  the set node (or line) numbers of all statements fragments in P prior to n that contribute to the values of variables in V at statement fragment n

15  For statement s and variable v, the slice of program P w.r.t. the slicing criterion includes only those statements of P needed to contribute (or influence) to the behavior of v at s.

16  1Y := X  2Z := Y  The value of X before the first statement can contribute to the value of Z after second ▪ S(Z,2)

17  The notion of contribution can be described by the USE relationship (e.g., C-use and P- use)  P-use: used in a predicate (decision)  C-use: used in computation (assignment)  O-use: used for output (write/print, etc.)  L-use: used for location (e.g., pointers/subscripts)  I-use: iteration (e.g., internal counter)

18  Definition nodes can be refined  I-def  I-def: defined by input (e.g., read)  A-def  A-def: defined by assignment statements (e.g., a:= x + y)

19  There are two properties in a slice  The slice must have been obtained from the original program by statement deletion  The behavior of the slice must correspond to the behavior of program as observed through the window of the slicing criterion

20  By removing the source code of a program, we may obtain slice that is not grammatically correct  E.g. removing the THEN clause from an IF-THEN- ELSE block

21 Important guideline for node inclusion in the slice: 1.If statement n is a defining node for v, the n is included in the slice 2.If statement n is a usage node for v, then n is NOT included in the slice 3.P-use/c-use of other variables are included if they their execution has some affects on the value of the variable v loop






27 Consider the slice S 5, which is S(locks,23)={22,23,24,29,30} This slice contains the following statements:

28 If we add statement 1-14 and 53, then we can compile the slice as follows:

29  Using SBT,  Program is decomposed into set of mini- programs or functions which are easier to test  The focus can be made on the most interesting parts of a program (smaller and/or simpler) or parts that implements properties  difficult using du-paths because du-paths are sequences that include both statements and variables

30 1. Never make a slice S(V,n) for which variables v  V do not appear in statement fragment n 2. Make slices on one variable 3. Make slices for all A-def nodes e.g., S 27 :S(sales,36)={3,4,5,19,20,21,22,23,24,25,26,27,28, 29,30,36} P-use node 4. Make slices for P-use node because the slice shows how the predicate variable gets its value 5. Stay away from non P-use slices 6. Consider making slices compile-able (executable)`

31  Metrics may include  Coverage: compares the lengths of slices to the length of the entire program ▪ Ratio of mean slice length to program length ▪ a low coverage value indicates a long program with many shorts slices (or properties )  Coupling (statements common to all slices)  Parallelism ( slices having a very few elements in common)

32  [Rapps 85] S. Rapps and E. Weyuker. Selecting software test data using data flow information. IEEE Transaction on Software Eng.,, no.4, pp:367-375, April, 1985.  [Frankl 88] P. Frankl and E. Weyuker. An Applicable Family of Data Flow Testing Criteria. IEEE Transaction on software eng., vol.14, no.10, October 1988.  [Weyuker 88] E. Weyuker. The evaluation of Program-based software test data adequacy criteria. Communication of the ACM, vol.31, no.6, June 1988.  [Jorgenson 95]. Software Testing: A Craftsman’s Approach. CRC publication, 1995.  [Jorgenson 02]. Software Testing: A Craftsman’s Approach. CRC publication, 2002, 2 nd edition.  [Weiser 88]. M. D. Weiser. Program slicing. IEEE Transaction on software eng. Vol.10, no.4, pg:352-357, April 1988.  [Gallagher 91] K. B. Gallagher, and J. R. Lye. Using program slicing in software maintenance. IEEE Transaction on Software Eng., vol.17, no.8, pg: 751-761.

Download ppt "Csci 565 Spring 2009.  Originally proposed by [Weiser 88]and [Gallagher 91] in software maintenance  Useful for  Software Debugging  Software Maintenance."

Similar presentations

Ads by Google