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:

2 comments:

  1. Hi there,

    Thanks a bunch for posting the solutions. I struggled with implementing recursive functions during the lab, and right now I'm reviewing my work.

    At first, I was confused with the solution I had for the arity function and the implementation you had for the same function. When I reread the definition of arity, I realized I misread it completely, and your solution makes more sense to me now!

    Again, thanks for posting your solutions and I hope you continue to do this for future posts :)



    ReplyDelete
    Replies
    1. I'm glad you found this helpful, I'll try to post solutions to all of the exercises I find tricky.

      Delete