Thursday, 20 February 2014

Week 7 - Recursion

    It has been several weeks since I've made a post and I feel that I have made great improvements in my programming skills and understanding of content. For example, I did not understand the property function at all, and I also felt that it was useless. However, after I went back to take a look at it once more, I finally understood its importance. It stops the user from changing an attribute of a class in a way that the programmer would not want it to be changed. We can do this by writing a setter method that is called every time the user tries to assign to an attribute of a class. We would also need a getter method otherwise the private attribute would be unreadable. I have even used the property function within some of my code so I feel that I am comfortable with it. This is just one of several topics that I feel I have progressed in. Others would be handling exceptions, object oriented programming, and inheritance. I have made progressions through several hours of practice, and by working through and completing assignment 1. I believe that lots of practice is the key to doing well in this course, at least it is for me because I often have trouble grasping the concepts at first sight during lecture.

    While I have progressed greatly in some aspects of this course, I still find recursion to be quite challenging. When we first started learning about it, I had absolutely no idea what was going on because I found that calling the function itself within its own definition was just mind boggling. Another reason for my struggles with recursion is that it is somewhat difficult to trace. I feel that there are so many things happening within it that I get confused while tracing it. I don't mean just tracing on paper but rather visualizing and dissecting what happens in each step. I feel that visualizing each step for a function helps me understand where potential problems might lie and how the function actually works but I have a considerably difficult time doing this with a recursive function call. After several weeks of working with it in lecture, the assignment, and in labs, I have understood some parts of a recursive function. For example, I acknowledge that there has to be a base case for the function to eventually reach otherwise recursion depth will be exceeded. With this information, I know that the first step to writing a recursive function is to write the base case first. I start having trouble with the rest of the function after this step. I am now able to write simple recursive functions such as the nested depth of a list or a sum of the elements in a nested list but I still require too much time to write some of the slightly more complex recursive functions. I believe that I require more practice with writing recursive functions because I have hardly attempted them outside of labs, lecture, and the assignment. I know that writing recursive functions is an essential tool for programming and so I will continue to practice with them until I am fully comfortable with them.