Friday, 27 February 2015

Summary of Recursion

    Recursion is certainly my favorite programming concept that we have covered this semester. This being said, beginning with the suggested style of tracing recursive code was much harder for me to wrap my head around than the code itself and I have since developed my own methods. Combining recursive code with list comprehensions was also somewhat easy for me and seemed quite logical. After a small amount of practice with writing basic functions using these ideas, both the lab exercises and our weekly quiz were exceptionally easy for me.

    Although I already posted about my thoughts on the combination of recursive code with trees, I feel that this topic is certainly worth revisiting in light of Assignment 2. As I mentioned in my last post, I generally spend a great deal of time studying the lab exercises before each weekly lab, I found this to be crucial in aiding my understanding of recursion with trees. The abstractness of this concept, although quite interesting, was very challenging for me to wrap my head around and I found that learning at home at my own pace with no time constraints allowed me to fully grasp these ideas. The true test of my abilities was the Minimax algorithm (in Assignment 2), even with my solid understanding of recursion with trees, I still found this to be extremely challenging. After roughly 5 hours of drawing pictures, madly typing code, and consuming large amounts of caffeine, I managed to fully complete Minimax and I feel that I have become a much stronger student as a result.

    Moving on to my first impressions of binary search trees, I find this concept somewhat challenging but not exceptionally difficult. With my relatively strong understanding of recursion in non-binary search trees and my study strategy of completing lab exercises at home, I am just starting to become more comfortable with writing functions that complete various tasks involving these objects. I certainly will need more practice beyond the Additional Exercises in this week's lab, so I may spend some time this weekend rewriting all of my solutions to lab #6.

These are my solutions to the Additional Exercises in Lab #6 (with corrected docstring examples). If anyone finds any bugs, please let me know in the comments.

Sunday, 15 February 2015

Summary of Object-Oriented Programming Concepts

    So far, I have been quite pleased with the course content of CSC148 and it's emphasis on object-oriented design. Our detailed discussion on classes has left me quite satisfied in adding a new approach to problem solving and a powerful tool to my arsenal of computer science knowledge. Beginning with basic class design, I felt very comfortable writing classes such as "point.py" (featured in lecture), and each week, each new addition to our Point seemed incredibly logical and simple for me to understand. As a result, our discussion on special methods also made much sense to me. I felt that I already had a basic understanding of this concept after CSC108, and these lectures only further increased my confidence with writing code of this sort. I felt precisely the same about inheritance, so I won't discus it further. Perhaps a topic I have not discussed in any great detail is my understanding of stacks and queues. I found this somewhat difficult to grasp initially, but after completing the lab exercises early, helping other students with their code, and completing all of the additional exercises in each lab, I feel that I have a very good understanding of how these objects work and their value to us as programmers. Moving on to recursion and trees, I very much enjoyed each of our discussions on both concepts. I have previously posted about my thoughts on recursion, however the combination of this concept with tree objects was an especially interesting challenge for me. So, in order to really strengthen my understanding and confidence, I spent a great deal of time tracing my code in my head for the lab exercises before executing; making sure that each function would work correctly.

    Also on the topic of stacks, I think Saman's idea to write a Hanoi tower puzzle game with stacks has the potential to be very interesting. Check out his post here.

    Moving on to the feedback I received for A1 and the midterm, I was quite relieved to see that I scored highly on both. On A1, I made a small mistake in an "__eq__" method, forgetting to compare the type of the two arguments (using the isinstance function), and also making a string class that only represented the winner in a GameState. These were small errors that are easily corrected and I think I could have avoided this if I had been more careful. With regards to the test, I made the same error as in my assignment (not comparing the type in "__eq__") as well as a silly mistake in my wording of one of my docstrings. Again, I think that in the future I should be spending more time looking closely for mistakes like these as they may cost me significantly more marks in the future.


These are my solutions for the Additional Exercises in Lab #5:

Friday, 6 February 2015

Test and Thoughts So Far

    I have had much time to reflect on the test given on Wednesday and have concluded that each question was exceptionally fair, exactly what we have been prepared for. The question on recursion was also very easy for me (hopefully I had the correct idea) which made it a very fun exercise for the topic I studied so carefully. As for my performance on said test, I feel that I knew all of the material and studied appropriately, however, I make a point of not trying to predict what my mark might be before I receive any grade.

    With regards to the discussion on Monday on test cases, I must say that I am very intimidated. Although I had a chance to practice with unittest in this week's lab, the topic was very difficult for me to accept last semester in CSC108. I think my issue was in my lack of understanding of how unittest works as a class and not knowing what the implementation of the method "unittest.TestCase" looks like. This being said, the actual implementation of a subclass of unittest.TestCase for a specific function is not at all a difficult concept for me and I do feel slightly more confident with this topic than in CSC108. Back to my confusion, the code seen under the "if __name__ == '__main__':" line in a test class continues to elude me. Why is it that "unittest.main(exit=False)" must be executed? What does "exit=False" do? I believe these are questions that I will have to answer on my own time, so perhaps this weekend I will read up on unittest to strengthen my understanding of this.

Also, I am not posting anything on recursion this week since I have nothing more to say about the topic. My thoughts on this can be found in last week's post.