Many of the questions in this chapter's exercise are "thought questions." The answers given here are typical or suggested responses, but are not the only possible answers.
1. Software engineering is a disciplined approach to the creation and maintenance of computer programs throughout their whole life cycle.
4. Some software tools used in developing computer programs are text editors, compilers, assemblers, operating systems, and debugging programs.
7. Goal 4 says, "Quality software is completed on time and within budget."
(a) When a student does not complete a programming assignment on time, it usually hurts his or her grade. Also, some concepts that were to be learned in preparation for the next programming assignment may not be mastered in time to be put into practice.
(b) When a team developing a highly competitive new software product does not complete its work on time, the company must continue to pay salaries, office rent, etc., increasing the "development cost" of the product. The product may go on the market late, after competing products have been released, hurting its sales. This may have an effect on the team members' professional evaluations (like a student's grade).
10. An object is an individual while a class is a description of a group of objects with similar properties and behaviors. Labrador dogs is an example of a class and Maggie is an example of an object.
14. An expert understanding of your programming language saves you time and debugging because (a) you can avoid syntax errors, (b) you can more quickly identify and correct those syntax errors that occur, and (c) you can avoid errors caused by a misunderstanding of the way the language works.
17. The body of the While loop is not in brackets.
The comments include the call to Increment.
The parameter to Increment is not a reference parameter.
20. Unittesting is the testing of a single unit of the program (for instance, a function). Integration testing is the testing of groups of already tested units to make sure that they interact correctly and that the whole program works according to its specification.
23. (a) The functional domain consists of the whole numbers from 0 to 100.
(b) It is possible to carry out exhaustive data coverage for this program.
(c) Devise a test plan for this program.
Input: All values from 1 to 100.
Expected Output: For input 0-59 F For input 60-69 D
For input 70-79 C
For input 80-89 B
For input 90-100 A
26. Life-cycle verification refers to the idea that program verification activities can be performed throughout the program's life cycle, not just by testing the program after it is coded.
29. (a) num and denom are both just integer values. Each can be either negative or positive. In a fraction the numerator carries the sign. The denominator should always be positive.
(b) IsNotProper needs to be changed to use the absolute value of the numerator. Function Initialize (or any constructor) should check to be sure the denominator is strictly positive and throw an exception if this is not the case.
(c) The following tests need to be added to the test plan.
Operation to Be Tested and Description of Action
Fraction is proper
Fraction is improper
Whole number is 3
Numerator is -1
Denominator is 4
2. Data encapsulation isthe separation of the physical representation of data from the applications that use the data at a logical (abstract) level. When data abstraction is protected through encapsulation, the data user can deal with the data abstraction but cannot access its implementation, which is encapsulated. The data user accesses data that is encapsulated through a set of operations specified to create, access, and change the data. Data encapsulation is accomplished through a programming language feature.
5. array, struct, union, and classes
8. The syntax of the component selector is the array name followed by the index of the desired item:
This test plan is a black box strategy with data values representing the end cases and a general case. For matrix operations, the end cases represent the size of the matrices, not the values stored in them. We assume that integer addition and subtraction are correct.
31. If functions GetMonthAsString and Adjust are called frequently, then the first version is more efficient because access to the string or number of days would be O(1). On the other hand, if these functions are called only once, it would be better to calculate these values and store them. The second alternative would require two new class variables, one to hold the string and one to hold the number of days, but the auxiliary arrays would no longer be need.