Saturday 1 March 2014

Week 7: Recursion

‘To understand recursion, one must first understand recursion'- made no sense to me initially. But now, I feel like I finally understand it. The moment that recursion clicked in my brain had to be one of the most euphoric moments in my life. My main issue with recursion was that  was too accustomed to using loops to get what I want. Another issue I had was in not understanding what base cases to use and how they were utilized. Even the simple factorial function seemed convulated to me.

For recursion to work, we call a function within the same function. It involves a base case and a condition that calls on the function. It reminds me of induction, which is something we are learning in MAT137 and CSC165 now. Recursion simplifies the problem greatly and makes functions more efficient. I have learned that practice makes perfect in computer science. I now feel quite comfortable with recursion(even with base cases, which I struggled with so much). I went on Codeacademy for extra practice with recursion and that helped greatly. Now, I am finding recursion quite enjoyable. Creating functions using recursion is similar to solving puzzles.

I also had the midterm this week, which I thought went pretty well as I did study a lot for it over reading week, but we shall see how it went!

Tuesday 18 February 2014

Week 6: Trees

Most of this week was spent finishing A1.  I don't even remember how many hours I spent figuring out the recursion in tour.py. Getting the function to be efficient was incredibly challenging, but I think I succeeded. This assignment has definitely honed my recursion skills.

Moreover, this week, we learned about trees. Trees are composed of roots, branches and leaves. Roots are parents of children, and branches connect parents to children. Nodes with no children are called leaves. Each child can just have one parent, and each parent can have a maximum of 2 children. The tracing of trees is done through recursion. They seem like a nifty way of handling and manipulating information and I look forward to getting more familiar with them.

Saturday 8 February 2014

Week 5: Assignment 1

This week, I started Assignment 1. I had to go over the assignment handout a few times, before I began to comprehend it. I know that the story at the beginning is supposed to make A1 seem like more fun, but it ended up just confusing me. So far, I am finding the assignment fair. I am done TOAHModel.py and am going to start ConsoleController.py tomorrow. Steps 1-4 did not take me a lot of time. However, I was stuck for quite a bit on the top_cheese function. After some investigating, I realized that the error lay in my __init__method, which I promptly fixed.

I know that the next part of A2 is more challenging as we have to use more advanced topics such as recursion. I am still not entirely sure if I understand recursion. Sometimes, I feel extremely confident in my ability to use recursion, whereas at other times, I feel completely lost. Furthermore, We went over the Tower of Hanoi recursive code in class today. It's interesting how recursion can provide the fastest way to complete the game. However, I do not think I followed entirely in class and I plan on going over the code tomorrow, as it is apparently useful in the second part of the assignment. I will delve into more detail about recursion in week 7, when it is the assigned SLOG topic, and hopefully, I will have a better grasp on it by then.

Friday 31 January 2014

Week 4: Exceptions, Inheritance, Testing and E2

In the last SLOG, I expressed the difficulties I encountered with exceptions. However, after some practice, this week, I am finding myself quite comfortable with the idea. Exercise 2, which dealt primarily with exceptions, aided in clearing the concept for me. This whole week, I was dreading the exercise, given my limited understanding of the topic, but now, after being done, I am quite pleased with it. Previously, an error in a program would cause the program to crash. However, with exceptions, we can now effectively deal with the errors. We can enable the program to keep running via the try-except method. Something I found really interesting is the ability to create my own exceptions. I have always wondered about invalid input in programs. In CSC108, we were taught to include preconditions in docstring to deter programmers from inputting invalid data. However, that was a mere guideline and did not accomplish much. By raising our own exception classes, we can control the input, as well we provide the user with information on what went wrong.

Another topic in 148 right now is inheritance, which is quickly becoming one of my favorite aspects of programming. Calling on functions in other classes is extremely useful and avoids redundant duplication of code. The lab this week was a lot of fun, as it heavily utilized inheritance. I found myself breezing through most of the lab. However, the part with unittest was a little challenging for me as I spent a large portion of time on it. In lecture, I thought that I understood unittest, however the lab demonstrated that I didn't. Choosing test cases and using assert methods were confusing to me but after struggling through that portion of the lab, I am feeling much more confident in my unittest skills.

This week, we also started recursion. I remember my TA from CSC108 being very excited about recursion and I have been looking forward to it ever since. I must confess that I do not fully grasp it at this point, but I am hoping that with more practice, I will master it.

Thursday 23 January 2014

Week 3: Object Oriented Programming

Having never done any programming prior to CSC108 last semester, I had gotten very used to procedural programming. Thus, object oriented programming did confuse me initially. Last semester, when we were introduced to classes, I was quite unsure of how they worked, and that was demonstrated very clearly in my final exam, where I very inadequately answered the question about classes. For example, I struggled to understand what self referred to and ended up using it incorrectly numerous times. However, this semester, I am finding the concept of object oriented programming much easier to understand. I now understand that self refers to the object itself and is useful when calling methods and using the class. While I heavily questioned the effectiveness or practicality of object oriented programming last semester, I am finding that I am actually quite enjoying it this semester. Particularly, it is very helpful in organizing large quantities of code. I found the readings provided in the course website to be quite helpful and further readings like those would be very appreciated.

ADTs also helped clear out the concept of OOP to me. The lab this week was very helpful and I enjoyed implementing and using stack and queue ADTs. The similarities and differences between these 2 ADTs, as well as the functionality of ADTs became much clearer to me after this lab. The difference in efficiency between these two ADTs is quite intriguing, in that stacks are generally fater than queues. However, something that I am currently struggling with is Exceptions, which is something we just started in class. I can see the usefulness of exception classes clearly, however it's hard to understand their implementation. In order to clear this up, I intend to do some more practice with exceptions and hopefully, by my next slog, I will have a much clearer grasp on what they entail.