Thursday, February 6, 2014

Week 4 - Recursion on nested lists, code/algorithm testing

     Hey there! It's been a while since I've made a post, so here it is! I will feature a double post today to make up for last week (for last week and this week).

Week four has been a huge step up from week three, as now I feel as if the class is heading more towards the algorithm direction of computer science rather than software engineering.

When designing a method or a function, it's a good idea to test out your methods rigorously. From what I remember from CSC108, which is considered as an "optional" prerequisite course, we have learned the function design recipe, and from that 'recipe', it dictates that we should come up with examples after you come up with the method header and type contracts. I found this rather counter-intuitive at first, as I had previous experience programming prior to the start of my post-secondary education, so I usually become lazy and just go on ahead with the coding. That only led me to problems. However, the examples that were given in class weren't that difficult to follow, and I did find it to be 'common sense'. To thoroughly test a method, you would need to come up with what I like to call, counterexamples. In other words, you have to come up with some sort of parameter inputs where it can possibly break your method. I find this to be the hardest part of designing any method or function, as I usually get a hunch that my code is almost always 'broken' in some form.

The main topic of the lecture was recursion. In Week 3, we have just lightly touched up on it. This week, we have went deeper into it. Recalling previous experience from my high school days, I remember the topic of recursion as the most disliked concept in my computer science class. Recalling from my previous post, recursion in a nutshell is calling a method or function inside itself repeatedly until a desired value is achieved. I think that this is the most challenging concept to master. I imagine that Euclid's greatest common denominator recursive algorithm took him months just to come up with it - it's quite a bit of an exaggeration of course, but I hope you understand what I mean. Tracing recursive methods are not as bad as creating them. They're actually quite easy to follow, as you can simply use your understanding of Python to understand what's happening at every step.

Reading Flexy's SLOG for week 4 (link below), he or she says that most CSC148 students haven't encountered recursive functions prior to the start of the course. I do believe that this is almost irrelevant, as I am almost certain that people with experience for recursive functions still have trouble with creating their own. As my lecturer pointed out, most programmers actually do not use recursion - I imagine it's because of the difficulty of creating one.

I think this will wrap up my Week 4 thoughts.

Here's a link to Flexy's SLOG: http://flexographyslog.blogspot.ca/

No comments:

Post a Comment