In my first four weeks in this course, I have learnt quite a lot, especially about classes and recursion. To me, the concepts are not too difficult, but they are not too simple either. The first thing that I learnt is to look for a few key things in a class description to design a class. I found this particularly useful. These things are: an important noun (for the class name), attributes, and necessary operations. For example, for a class Point, its attributes are the x and y coordinates, and its necessary operations can be calculating the distance between a point and the origin, distance between two points and the midpoint between the two points. I also learnt how to implement an __eq__, __str__ and __repr__ method. Interestingly, the concept of controlling access to attributes and classes was also taught. Because of this, I now know that _attribute represent an attribute that can be controlled by the creator. Additionally, I also learnt how a stack is designed, and the three main functions associated with this class, push(), pop() and is_empty().
As well, the professor covered how to extend a class's (superclass) characteristics in a subclass. Also, for methods in a superclass that are supposed to be in a subclass, all one has to do is raise an exception (ex. raise Exception("This cannot be done.")). One can raise existing Exceptions, or make up his or her own Exceptions. Furthermore, I learnt how to trace through a list to add items up in a process known as recursion. Recursion is a very interesting and unique concept as it involves a function calling itself. One can use this method to trace lists of varying depths, like this:
sum_list[1, 2, 3, 4, 5, 6] or sum_list [1, [2, 3], 4, 5, 6] or even sum_list[1, 2, [3, 4, [5, 6], 7], 8]
We were given weekly lab exercises based on what we were taught, and quizzes in our tutorials. I found the quizzes quite tough, actually. I was confused about how to answer the questions, so I didn't end up doing well on them. The concepts are easy to understand, but applying them requires a lot of thinking and can be difficult for me. This is why I plan to ask for help from various people, including TA's at the help centre. Despite the challenges, this course has been interesting so far, and I am looking forward to learning more about advanced programming.
As well, the professor covered how to extend a class's (superclass) characteristics in a subclass. Also, for methods in a superclass that are supposed to be in a subclass, all one has to do is raise an exception (ex. raise Exception("This cannot be done.")). One can raise existing Exceptions, or make up his or her own Exceptions. Furthermore, I learnt how to trace through a list to add items up in a process known as recursion. Recursion is a very interesting and unique concept as it involves a function calling itself. One can use this method to trace lists of varying depths, like this:
sum_list[1, 2, 3, 4, 5, 6] or sum_list [1, [2, 3], 4, 5, 6] or even sum_list[1, 2, [3, 4, [5, 6], 7], 8]
We were given weekly lab exercises based on what we were taught, and quizzes in our tutorials. I found the quizzes quite tough, actually. I was confused about how to answer the questions, so I didn't end up doing well on them. The concepts are easy to understand, but applying them requires a lot of thinking and can be difficult for me. This is why I plan to ask for help from various people, including TA's at the help centre. Despite the challenges, this course has been interesting so far, and I am looking forward to learning more about advanced programming.
No comments:
Post a Comment