Skip to content

Commit 5ddc2d5

Browse files
committed
use meaningful xml:ids
1 parent 3e78cb0 commit 5ddc2d5

2 files changed

Lines changed: 9 additions & 12 deletions

File tree

source/ch6_definingclasses.ptx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ public class Fraction extends Number implements Comparable<Fraction> {
10111011
</program>
10121012
</section>
10131013

1014-
<section xml:id="chapter6_summary">
1014+
<section xml:id="java_classes_summary">
10151015
<title>Summary &amp; Reading Questions</title>
10161016
<p><ol>
10171017
<li>

source/ch7_recursion.ptx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -324,14 +324,14 @@ public class ArrayProcessor {
324324
public static void main(String[] args) {
325325
System.out.println("Calling the recursive method... this will end in an error!");
326326

327-
causeStackOverflow();
327+
causeStackOverflow();
328328
}
329329
}
330330
</code>
331331
</program>
332332
</section>
333333

334-
<section xml:id="recursion_java_summary">
334+
<section xml:id="recursion_summary">
335335
<title>Summary &amp; Reading Questions</title>
336336
<p><ol label="1">
337337
<li>
@@ -344,23 +344,20 @@ public class ArrayProcessor {
344344
<p>The recursive logic in Java mirrors Python conceptually, but Java uses curly braces <c>{}</c> and explicit types instead of indentation and dynamic typing.</p>
345345
</li>
346346
<li>
347-
<p>The helper-method pattern keeps public APIs clean (e.g., <c>sumArray(int[] arr)</c>) while a private helper (e.g., <c>sumHelper(int[] arr, int index)</c>) carries extra state like the current index.</p>
348-
</li>
349-
<li>
350-
<p>Closing over array bounds and indexes in the helper avoids forcing callers to provide implementation details (like a starting index).</p>
347+
<p>The helper method pattern hides implementation details (like array indices) from callers, providing clean public interfaces while managing recursive state privately.</p>
351348
</li>
352349
<li>
353350
<p>Deep or unbounded recursion can exhaust the call stack: Python raises <c>RecursionError</c>; Java throws <c>StackOverflowError</c>.</p>
354351
</li>
355352
<li>
356-
<p>Neither Java nor Python guarantees tail call optimization; prefer iterative solutions for algorithms requiring very deep recursion.</p>
353+
<p>Neither Java nor Python guarantees tail call optimization, so programmers should use iterative solutions for algorithms that would require very deep recursion.</p>
357354
</li>
358355
<li>
359-
<p>Error signaling differs across languages; for example, a Java factorial that receives a negative <c>n</c> might return a sentinel value (e.g., <c>-1</c>) after printing an error message.</p>
356+
<p>Recursive methods in Java must specify return types explicitly, unlike Python's dynamic typing, which affects how you handle error cases and return values.</p>
360357
</li>
361358
</ol></p>
362359
<reading-questions xml:id="rqs-recursion-java">
363-
<exercise label="recursion-1">
360+
<exercise label="recursion-method-signature">
364361
<statement>
365362
<p>Which method signature and behavior best match a typical Java recursive factorial implementation?</p>
366363
</statement>
@@ -383,7 +380,7 @@ public class ArrayProcessor {
383380
</choice>
384381
</choices>
385382
</exercise>
386-
<exercise label="recursion-2">
383+
<exercise label="recursion-helper-method">
387384
<statement>
388385
<p>Why use a private helper method (e.g., <c>sumHelper(int[] arr, int index)</c>) behind a public method (e.g., <c>sumArray(int[] arr)</c>) in recursive array processing?</p>
389386
</statement>
@@ -406,7 +403,7 @@ public class ArrayProcessor {
406403
</choice>
407404
</choices>
408405
</exercise>
409-
<exercise label="recursion-3">
406+
<exercise label="recursion-limits">
410407
<statement>
411408
<p>Which statement about recursion limits and errors is accurate?</p>
412409
</statement>

0 commit comments

Comments
 (0)