Agile Java Errata

14
Technically, the Agile Java definition of encapsulation is that of information hiding. A more precise definition of encapsulation is “the inclusion of both the methods and the data within an object.” The Agile Java definition is still correct but is closer to the more generalized definition of encapsulation: “the inclusion of one thing within another so that the included thing is not apparent.”
14
In the first paragraph, “I send you a message to you” should read “I send you a message.”
45
The first sentence of the first paragraph is more accurately written as: “In the second statement, Java assigns the memory address of this returned String object to a String local variable, defined on the left hand of the statement as studentName.”
45
The caret in the first compilation error listing should appear directly beneath the letter s in student.getName().
17
The footnote reference should be [Fowler2003], not [Fowler2000].
62
“Exercises appear at the end of lesson” should read “Exercises appear at the end of each lesson.”
77
In the first paragraph, replace:
Each time the getNumberOfStudents message is sent
with:
Each time the getAllStudents message is sent
77
In Figure 2.4, the variable names listed in the table to the right should read student1 and student2.
80
Second to last sentence on the page, “CourseSesson” should be “CourseSession.”
91
The header for the page should read “Deprecation Warnings,” not “Depreciation Warnings.”
100
The reference to TestPawn in exercises 1 should be changed to PawnTest.
101
The reference to TestPawn in exercises 7 should be changed to PawnTest.
113
In the third bullet, replace:
testReport constructs its own CourseSession object
with:
testRosterReport constructs its own CourseSession object
116
In the code for testCreateDate, replace:
Calendar calendar = new GregorianCalendar();
with:
GregorianCalendar calendar = new GregorianCalendar();
(I haven’t talked about assignments to the interface type yet.)
120
replace:
If you haven’t already done so, remove the testReport method from CourseSessionTest
with:
If you haven’t already done so, remove the testRosterReport method from CourseSessionTest
120
replace:
you can decompose the code in writeReport
with:
you can decompose the code in getReport
121
At the start of the third paragraph, replace:
move the studentinfo package down a level so that it is in a package named sis.reportinfo.
with:
move the studentinfo package down a level so that it is in a package named sis.studentinfo.
123
In the last paragraph, first sentence, replace:
from the code in the reports package
with:
from the code in the report package
Also make the same replacement in the second paragraph on the page.
139
The first sentence of the 2nd paragraph should read “The CourseSessionTest method testCount…”
141
The code should use the newer construct session = createCourseSession(); instead of CourseSession.create(...)
144
In the third paragraph, “Supplies a a shortcut” should read “Supplies a shortcut.”
169
The first sentence of the first paragraph should read “You can use interfaces to break dependencies…”
170
In the sidebar “More on this,” replace:
In the Student compareTo method
with:
In the CourseSession compareTo method
180
The Student class declaration should not include the clause implements Comparable<Student>
187
The Student class declaration should not include the clause implements Comparable<Student>
199
In the final paragraph in the Maps section, replace
Add a new class named ReportCardTest to the sis.reports package.
with:
Add a new class named ReportCardTest to the sis.report package.
202
The last sentence in the first paragraph should read “As a subclass, each of RegularGradingStrategy and HonorsGradingStrategy obtain all of the behaviors of BasicGradingStrategy.”
227-228
The text on p.228 says “Also important is that the return type for the create method in SummerCourseSession and CourseSession is the abstract supertype Session.” Technically this is the best idea, but not essential–Java allows for covariant return types. In any case: here are the relevant snippets for what the code on p227 looks like after making that change. (Thanks Luke!)

   // in CourseSession.java, create should declare a return type of Session, not CourseSession:
   public static Session create(
      String department,
      // ....

   // in SummerCourseSession.java, create should declare a return type of Session, not SummerCourseSession:
   public static Session create(
      String department,
      // ...

Unfortunately there’s a little bit of ripple effect. You will also get some errors in the report test/code. Just follow the compile errors, and wherever you use the result of a create method call, you’ll need to change the type of the variable to which it’s assigned (either a local or a parameter) to be Session.

If that’s confusing: Please take a look at the Github repo for end-of-chapter 6. I’ve made some corrections to the downloadable source (I’m not sure it was really “end of chapter” source), and also added support for loading the project via Gradle.

228
In the proposed example code, replace:
Session session = createSession(new Date());
with:
Session session = createSession("", "", new Date());
Better yet would be to add a createSession helper method that takes no arguments.
234
The while loop example uses a StringBuffer instead of a StringBuilder. This really isn’t a problem since we’ve already discussed StringBuffer, but under J2SE 5.0 you will probably want to prefer use of the new StringBuilder class.
234
The tokenize method at the bottom of the page should be named split.
235
Eliminate the line comment from the first code listing.
238
In the for loop statement in isPalindrome, the code should read:
forward++, backward--)
i.e. with two hyphens (minus signs) after backward. (It actually does have two hyphens, but the typeface used makes them appear as one.)
242
Fibonacci is a bad, bad example to use for recursion. Write a test that determines fib(100) and see how long it takes.
246
The footnote should refer to BitSet, not “BitSit.”
273
“CheckedExceptinos” should be “CheckedExceptions.”
338
After adding testKeys, getMessages method should be changed to public.
342
In Table 9.1, the entry for “range” is blank (and “range” should be in the sans serif font). The entry should read “Creates an enum set initially containing all of the elements in a from-to enum range.”
372
The story icon should appear beside the following paragraph, the one that starts with “You must assign passwords to students…”
374
In the last paragraph, replace java.util.SecureRandom with java.security.SecureRandom.
441
In the first code listing on the page, the assertion should read: assertTrue(classes.contains("sis.testing.SuiteBuilderTest.class"));
444
Add the following code to the listing:

public TestSuite suite() {
   TestSuite suite = new TestSuite();
   for (String className: gatherTestClassNames()) {
      Class klass = createClass(className);
      suite.addTestSuite(klass);
   }
   return suite;
}
528
“You can quickly add some time safety” should be “You can quickly add some type safety”
597
The bottom compartment in the diagram shown in Figure 6 should read “South.” Duh.
690
In the second line of the static initializer, the string literal should end with \\n instead of \\.
693
The method getErrorOutput should return errorOutput.toString(), not output.toString().
705
With respect to the definition for encapsulation, see the errata entry above for page 14.
733
[Bloch2001] should show Bloch, Joshua as the author of Effective Java Programming Language Guide

Atom