Thursday, 31 March 2016

Week 11 - A look back at Week 7

In Week 7 I discussed recursion, and the method by which I was originally taught how to implement recursive code. I said that when I was first learning recursion " I was taught to never try and trace the program, but instead rely on constructing robust base cases, and sound logic in making the recursive calls."


Upon working a bit more with recursion I still think this is one of the best ways to introduce recursion to students who have never worked with it. While I see the values of tracing recursive calls I think it can be misleading from one of the keys of recursion - the base cases. I don't know many of my peers in this course, but overhearing others work through some of the recursion exercises in my lab I heard people getting hung up on going step by step through what was taking place in their recursive calls, instead of focusing on whether or not the logic they used to construct their base cases was sound. Writing accurate docstring as a template for your recursive call and implementing based solely on those ideas can often bring you close (or all the way) to a perfectly implemented method. 

Another point of emphasis I've noticed in this course that has puzzled me slightly has been the focus on writing (relatively) complicated list comprehensions in order to produce more compact code. While I see the value in comprehensions, I've seen one or two examples of students trying to write an entire method in a single, complex comprehension. One line solutions to a problem can be incredibly satisfying, but in my opinion can often hinder the readability of your code. I much prefer if my partner produces 5 or 6 lines of clean code that is more readable, intuitive, and produces an equally correct solution. Maybe that's just me though.

All in all the semester is winding down. I'm looking forward to a relatively low-key exam period (only three exams) and starting the summer off on a positive note. 

No comments:

Post a Comment