Published online by Cambridge University Press: 03 September 2009
Presented in this appendix are four examples showing in various degrees of detail how the present method can be applied to programs written in C++.
Example A.1 shows how to insert constraints into a program to form a subprogram representing an execution path. It also shows how the rules developed in Chapter 3 can be used to simplify the subprogram to the extent possible.
Example A.2 shows that the present method is not only applicable to an execution path but also to the one that includes a loop construct as well. The analysis is done for all possible execution paths in the program, and thus the result constitutes a direct proof of the correctness.
The program in Example A.3 is adopted from a legacy software tool. A portion of this program (printed in boldface type) is difficult to understand. When the present method was used to analyze that part of the program, it was found that it consists of only nine feasible execution paths, despite of the fact that it contains three “for” loops and six “if” statements. Furthermore, it was found that all the path subprograms can be greatly simplified to explicate the function of the program.
The program in Example A.4 is a stack class. It is used to illustrate how the present method can be applied to an object-oriented program.
To save this book to your Kindle, first ensure [email protected] is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.
Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.
Find out more about the Kindle Personal Document Service.
To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.
To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.