So, take a Java statement like this one, given some int n
:
if ((n+"").length() == (((n+1)+"").length())) {
Or perhaps this one, given some double, temperature
, and some method that returns a boolean, unHatched()
:
while (temperature < 100 && unHatched())
In both of these cases, multiple auto-casts are made during the evaluation of the statement, and in both cases, the final determination is a boolean that is passed into some sort of control structure.
In my work with gifted students, the most that I have ever had to do to help someone understand statements like these is to do a simple trace. We write the statement down, mark each item by its type, and then cross off areas of the statement (and write down the new types) as we walk through the evaluation. This method has worked pretty consistently with my students at my day-job.
However, lately I have begun tutoring an adult student who is having a great deal of trouble, and I have been struggling to break apart statements like the above examples in ways that he can parse and keep straight.
He is at the right point, curricularly-speaking, to be examining them, but I am really struggling to help him trace and understand such statements. (Ironically enough, because he can guess and modify a statement repeatedly, he can actually write statements like these with a fair amount of success, though when he is finished, he no longer fully understands them.)
For various reasons, learning a small concept usually takes him 3-5 weeks. This timescale is fine, it is simply the speed at which he operates. However, this adds a constraint for me: approaches that I take to the material must lend themselves to a fair amount of repetition with only very minor variations, or they won't be effective.
I am really having trouble finding a good approach here. How can I give him the tools to break down statements with complex data type transformations?
while (temperature < 100 && unHatched())
, has no cast or type conversion:<
takes 2 comparable, and returns a boolean, then&&
takes 2 booleans and returns a boolean, thenwhile
takes a boolean. $\endgroup$