1. You discuss the difference between referential equality
(objects) versus value equality (primitives) in Lesson 6.
As I recall, you described it as primitive types stored on
the stack as contrasted to objects stored on the heap. This
is great information for computer science grads with perhaps
more knowlege about data structures, but I would suggest
a few more words about what are stacks and heaps for the
novice. The examples you chose illustrate the concepts
well.
2. Tracing recursion visually via the debugger is an
original idea. I wish I had thought of it myself :-)
We are stuck with the old factorial example since it is
so simple to code and grasp even though no one would ever
use such a routine in real life due to inefficiences.
I prefer your code to the terse textbook style of:
public static int factorial(int n) {
if (n <= 1) return 1;
else return n * factorial(n - 1);
}
Introducing the local variable 'result' makes the code
easier to read and debug. I would just modify your
example slightly to have just a single return which
returns the result.
if (n <= 1) // base case
result = 1;
else
result = n * factorial(n - 1);
return result;
Overall, I thought the debugging tutorial was outstanding.
I learned a few new tricks myself!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi. Thanks for your compliments and your very thoughtful suggestions on both of these tutorials. I'm not sure when I will do a revised version of these. I may wait another year for the next Eclipse release. But I do plan to revise them, and when I do I will certainly incorporate your ideas. Thanks again. Mark
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I really liked the Debugging lessons. It shows off the
power of screencasting as a learning tool.
Just a few observations:
---------------------------------------------------------
1. You discuss the difference between referential equality
(objects) versus value equality (primitives) in Lesson 6.
As I recall, you described it as primitive types stored on
the stack as contrasted to objects stored on the heap. This
is great information for computer science grads with perhaps
more knowlege about data structures, but I would suggest
a few more words about what are stacks and heaps for the
novice. The examples you chose illustrate the concepts
well.
2. Tracing recursion visually via the debugger is an
original idea. I wish I had thought of it myself :-)
We are stuck with the old factorial example since it is
so simple to code and grasp even though no one would ever
use such a routine in real life due to inefficiences.
I prefer your code to the terse textbook style of:
public static int factorial(int n) {
if (n <= 1) return 1;
else return n * factorial(n - 1);
}
Introducing the local variable 'result' makes the code
easier to read and debug. I would just modify your
example slightly to have just a single return which
returns the result.
if (n <= 1) // base case
result = 1;
else
result = n * factorial(n - 1);
return result;
Overall, I thought the debugging tutorial was outstanding.
I learned a few new tricks myself!
Hi. Thanks for your compliments and your very thoughtful suggestions on both of these tutorials. I'm not sure when I will do a revised version of these. I may wait another year for the next Eclipse release. But I do plan to revise them, and when I do I will certainly incorporate your ideas. Thanks again. Mark