The other day I was working on a code project and ran into a frustrating bug. I looked at it for at least an hour and got nowhere with it. I used breakpoints, debugging code, and scanned though the listing again and again. No joy. I had to leave for a meeting and so put it aside for several hours. When I got home that night I decided to take another look and within five minutes I found the problem. It was in a section of code that somehow I had neglected to look it. I was too close to the problem earlier. This happens a lot.
Somehow I think that after a break we return and our brain has done some processing we are not aware of. Or perhaps after a break we use a different part of our brain to get back into the problem and that results in a new view of the code. I’m not at all sure other than something changes when you put code aside and come back later.
I see a different sort of view change working with others. Very often a student will call me over to help them with a problem. As they are explaining the problem and what the code is doing they will often suddenly blurt out “never mind. I see it now.” Something about explaining the issue to someone else changes how we look at the problem. Sometimes that is enough to help us see a solution that was eluding us before. I should say that I saw this frequently working as and with professional developers over the years. It is not unique to beginners by any means. It’s probably common in all problem solving situations.
Clearly though sometimes we need to take a mental break from one problem so that we can find a different approach or a second set of eyes. Or a third set.
The question for me becomes how to teach students to find different views into their work. Pairs programming is one possibility especially as it forces communication. Requesting that students ask peers to review code maybe. Or even asking students to describe in regular works what is going on. Or maybe just showing it by example. Something to ponder this weekend I guess.
Alfred, taking a mental break works wonders for me also. I used pair programming for the first time last year with my students. For the most part it worked extremely well and when I was called over to take a look there was a greater chance that between the 2 of them they would discover the problem as they describe it to me.
ReplyDeleteThis year I'm at IBM (out of the classroom) and I ran into a problem the other day and a quick IM to a developer in India (it was 1am my time) asked the right question to help me fix my own problem.
Collaboration works at school and at work.
I have had epiphanies during a bathroom break, while driving home (after having finally let go), or in the shower. Or, as your students have, while explaining the problem to another person. When I worked at a software company, another woman and I developed an arrangement whereby one of us would walk into the other's office and say something like this: "Would you pretend to listen while I explain a problem so I can figure it out?" (If students resist explaining it to someone else, you can't them a pass to take a shower or drive home, but you could send them to the bathroom!)
ReplyDeleteI had the same experience last summer learning Scratch. I was ready to throw in the towel and start over, but instead went to bed. The next day, when I looked at it, the answer jumped out at me! Sometimes a pair of fresh eyes, or a fresh rested brain, is all you need.
ReplyDelete