Microsoft KB Archive/884775

= Code Complete Second Edition comments and corrections =

Article ID: 884775

Article Last Modified on 8/8/2007

-

APPLIES TO


 * MSPRESS Code Complete Second Edition

-



SUMMARY
This article contains comments, corrections, and information about known errors relating to the Microsoft Press book Code Complete Second Edition, 0-7356-1967-0.

The following topics are covered:


 * Page 65: Incorrect Information About JavaScript
 * Page 81: Incorrect Information Regarding Classes
 * Page 226: Error Should Be ErrorToReport
 * Page 229: Incorrect Page Numbers
 * Page 240: Option Explicit Should Be Num
 * Page 266: Error in Code Sample
 * Page 267: &quot;roots&quot; used in place of &quot;solutions&quot; in code samples
 * Pages 294 and 295: All Instances of 100,000 Should Be 1,000,000
 * Page 295: Missing Minus Sign
 * Pages 330-332: Error in Code Samples
 * Page 330: Missing Reference to C
 * Page 330: C++ Should Be C
 * Page 330: C++ Example Should Be C Example
 * Page 330: Missing Information Regarding C++
 * Page 331: Invalid Statement
 * Page 333: Reference Should Be Value
 * Page 333: Value Should Be Reference
 * Pages 402-405: Wend Should Be End While
 * Page 422: &quot;}&quot; Should Be &quot;};&quot;
 * Page 422: Field_Last should be Field_Last+1
 * Page 423: &quot;and&quot; Should Be &quot;&&&quot;
 * Page 512: &quot;line 15&quot; Should Be &quot;line 12&quot; In Table
 * Page 610: x Is Not Greater Than 5
 * Page 613: &quot;C++&quot; Should Be &quot;C#&quot;
 * Page 614: Minus sign missing from table
 * Page 619: Error In Code Sample
 * Page 641: Two extra lines included in code sample
 * Page 655: &quot;architecture&quot; used in place of &quot;architecture and requirements&quot;
 * Page 752: Errors In Code Sample
 * Page 758: Incorrect Listing Reference
 * Page 770: Maximum referenced in place of minimum
 * Page 779: Error In First Code Sample
 * Page 779: Error In Second Code Sample
 * Page 858: Incorrect Address



Page 65: Incorrect Information About JavaScript
There is an error regarding JavaScript on page 65.

Change:

&quot;JavaScript is an interpreted language that is loosely&quot;

To:

&quot;JavaScript is an interpreted language that was originally loosely&quot;

Page 81: Incorrect Information Regarding Classes
There is an error in the first paragraph on page 81.

Change:

&quot;the number of routines called from within a routine or from within a class&quot;

To:

&quot;the number of routines called from within a routine or the number of classes used within a class&quot;

Page 226: Error Should Be ErrorToReport
There is an error on page 226 after the code sample.

Change:

&quot;Italicized variable name 'error'&quot;

To:

&quot;Italicized variable name 'errorToReport'&quot;

Page 229: Incorrect Page Numbers
On page 229, there is an error in the 2nd paragraph:

Change:

&quot;Now look again at the spec on page 000 and the initial pseudocode on page 000.&quot;

To:

&quot;Now look again at the spec on page 221 and the initial pseudocode on page 224.&quot;

Page 240: Option Explicit Should Be Num
There is an error in the middle of page 240.

Change:

&quot;common suffixes such as Option Explicit and No&quot;

To:

&quot;common suffixes such as Num and No&quot;

Page 266: Error in Code Sample
There is an error in the second code sample on page 266.

Change:

&quot;if ( recalcNeeded == True )&quot;

To:

&quot;if ( recalcNeeded = false )&quot;

Page 267: &quot;roots&quot; used in place of &quot;solutions&quot; in code samples
On page 267, the second and third code samples read:

C++ Example of an Uninformative “Temporary” Variable Name // Compute roots of a quadratic equation. // This assumes that (b^2-4*a*c) is positive. temp = sqrt( b^2 - 4*a*c ); root[0] = ( -b + temp ) / ( 2 * a ); root[1] = ( -b - temp ) / ( 2 * a );

C++ Example with a “Temporary” Variable Name Replaced with a Real Variable // Compute roots of a quadratic equation. // This assumes that (b^2-4*a*c) is positive. discriminant = sqrt( b^2 - 4*a*c ); root[0] = ( -b + discriminant ) / ( 2 * a ); root[1] = ( -b - discriminant ) / ( 2 * a );

They should read:

C++ Example of an Uninformative “Temporary” Variable Name // Compute solutions to a quadratic equation. // This assumes that (b^2-4*a*c) is positive. temp = sqrt( b^2 - 4*a*c ); solution[0] = ( -b + temp ) / ( 2 * a ); solution[1] = ( -b - temp ) / ( 2 * a );

C++ Example with a “Temporary” Variable Name Replaced with a Real Variable // Compute solutions to a quadratic equation. // This assumes that (b^2-4*a*c) is positive. discriminant = sqrt( b^2 - 4*a*c ); solution[0] = ( -b + discriminant ) / ( 2 * a ); solution[1] = ( -b - discriminant ) / ( 2 * a );

Pages 294 and 295: All Instances of 100,000 Should Be 1,000,000
There are multiple typographical errors in the last paragraph on page 294, and the first paragraph on page 295.

Change all instances of:

&quot;100,000&quot;

To:

&quot;1,000,000&quot;

Page 295: Missing Minus Sign
There is a minus sign missing from the first paragraph on page 295.

Change:

&quot;727,379,968&quot;

To:

&quot;-727,379,968&quot;

Pages 330-332: Error in Code Samples
The code samples on pages 330, 331, and 332 contain incorrect data. The lines of code beginning with &quot;memset( pointer&quot; should be removed.

Page 330: Missing Reference to C
There is a typographical error in the fourth paragraph on page 330.

Change:

&quot;You can force errors&quot;

To:

&quot;In C, you can force errors&quot;

Page 330: C++ Should Be C
There is a typographical error in the fourth line of the fourth paragraph on page 330.

Change:

&quot;C++&quot;

To:

&quot;C&quot;

Page 330: C++ Example Should Be C Example
There is an error in the first code sample on page 330.

Change:

&quot;C++ Example&quot;

To:

&quot;C Example&quot;

Page 330: Missing Information Regarding C++
There is an error in the first line of the fifth paragraph on page 330.

Change:

&quot;Of course, this technique requires&quot;

To:

&quot;Of course, this technique will not work in C++ where the pointer points to an object, and it requires&quot;

Page 331: Invalid Statement
On page 331, there is an error in the second to the last line.

Change:

&quot;It can also check for a null return ...&quot;

To:

&quot;It can also be checked for an exception or a null return ...&quot;

Page 333: Reference Should Be Value
On page 333,

Change:

&quot;Sometimes, however, you would like to have the semantics of a pass by reference&quot;

To

&quot;Sometimes, however, you would like to have the semantics of a pass by value&quot;

Page 333: Value Should Be Reference
On page 333,

Change:

&quot;with the implementation of a pass by value&quot;

To:

&quot;with the implementation of a pass by reference&quot;

Pages 402-405: Wend Should Be End While
In the code samples on pages 402-405, &quot;Wend&quot; should be changed to &quot;End While&quot; in the following locations:

Page 402, first code sample, 4th line from bottom;

Pages 403 and 404, first code sample, 3rd line from bottom;

Page 405, first code sample, 5th line from bottom.

Page 422: &quot;}&quot; Should Be &quot;};&quot;
There are two errors in the first code sample on page 422.

In the 4th line, change the first &quot;}&quot; to &quot;};&quot;

In the 10th line, change the last &quot;}&quot; to &quot;};&quot;

Page 422: Field_Last should be Field_Last+1
On page 422, +1 is missing from the second code sample on the page.

Change:

AbstractField* field[ Field_Last ];

To:

AbstractField* field[ Field_Last+1 ];

Page 423: &quot;and&quot; Should Be &quot;&&&quot;
There is an error in the code sample on page 423.

Change:

&quot;and&quot;

To:

&quot;&&&quot;

Page 512: &quot;line 15&quot; Should Be &quot;line 12&quot; In Table
Case 8 in the table on page 512 contains an error.

Change:

&quot;line 15&quot;

To:

&quot;line 12&quot;

Page 610: x Is Not Greater Than 5
There is an error in the 3rd paragraph on page 610.

Change:

&quot;Once you've determined that x is greater than 5&quot;

To:

&quot;Once you've determined that x is not greater than 5&quot;

Page 613: &quot;C++&quot; Should Be &quot;C#&quot;
There are two errors in the 2nd paragraph on page 613.

Change both instances of:

&quot;C++&quot;

To:

&quot;C#&quot;

Page 614: Minus sign missing from table
On page 614, the Time Savings column of the Visual Basic row of the table reads:

&quot;258%&quot;

It should read:

&quot;-258%&quot;

Page 619: Error In Code Sample
There is an error in the 1st code sample on page 619.

In the 3rd line from the bottom,

Change:

&quot;if ( i == count )&quot;

To:

&quot;if ( i == count - 1 )&quot;

Page 641: Two extra lines included in code sample
On page 641, the var section of the first code sample reads:

var index: integer; lowerByte: byte; upperByte: byte; targetIndex: integer;

It should read:

var index: integer; targetIndex: integer;

Page 655: &quot;architecture&quot; used in place of &quot;architecture and requirements&quot;
On page 655, the second and third sentences of the second paragraph read:

&quot;Barry Boehm and Richard Turner found that spending about five percent of total project costs on architecture produced the lowest cost for projects in the 10,000-lines-of-code range. But for projects in the 100,000-lines-of-code range, spending 15–20 percent of project effort on architecture produced the best results (Boehm and Turner 2004).&quot;

They should read:

&quot;Barry Boehm and Richard Turner found that spending about five percent of total project costs on architecture and requirements produced the lowest cost for projects in the 10,000-lines-of-code range. But for projects in the 100,000-lines-of-code range, spending 15–20 percent of project effort on architecture and requirements produced the best results (Boehm and Turner 2004).&quot;

Page 752: Errors In Code Sample
There are two errors in the middle code sample on page 752.

Change:

&quot;if ( mainColor = BallColor_White&quot;

To:

&quot;if ( mainColor == BallColor_White&quot;

And change:

&quot;if ( mainColor = BallColor_Blue&quot;

To:

&quot;if ( mainColor == BallColor_Blue&quot;

Page 758: Incorrect Listing Reference
There is an incorrect listing reference 3/4 of the way down page 758.

Change:

&quot;In Listing 31-45&quot;

To:

&quot;In Listing 31-47&quot;

Page 770: Maximum referenced in place of minimum
On page 770, the 23rd line of the code sample reads:

// find the arithmetic maximum of arg1 and arg2

It should read:

// find the arithmetic minimum of arg1 and arg2

Page 779: Error In First Code Sample
There is an error in the 1st code sample on page 779.

Change:

&quot;for ( i = 1;&quot;

To:

&quot;for ( i = 2;&quot;

Page 779: Error In Second Code Sample
There is an error in the 5th line from the bottom of the 2nd code sample on page 779.

Change:

&quot;for ( primeCandidate = 1;&quot;

To:

&quot;for ( primeCandidate = 2;&quot;

Page 858: Incorrect Address
The address in the 2nd paragraph from the bottom of page 858 is not valid.

Change:

&quot;write: ACM, PO Box 12114, Church Street Station, New York, NY 10257&quot;

To:

&quot;see www.acm.org.&quot;

Microsoft Press is committed to providing informative and accurate books. All comments and corrections listed above are ready for inclusion in future printings of this book. If you have a later printing of this book, it may already contain most or all of the above corrections.

Additional query words: 0-7356-1438-5 978-0-7356-1967-8

Keywords: kbdocfix kbdocerr KB884775

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.