Tuesday, 22 October 2013

Assignment 1 Feedback (Week of Oct 14th)

I took almost the whole weekend last week to finish Assignment1! But I felt really accomplished when seeing the animation work! Completing part 1 and 2 wasn't too hard, because you just have to store instance variable to a class and write methods header. Part 3 was a bit annoying because I need to first understand what each method in DomainStools does in the ManuelController class, then implementing it. The method 'add' and 'move' took me around 2 hours to finish. At first, I did not understand what ‘add’ does because DomainStools has nothing to do with graphics of the cheese or the canvas. After a while, I realized it is used for restricting which cheese you can move. For method 'move', I had problem distinguishing the bottom cheese (stool) because they all have the same size. Thus by just checking the size of the bottom cheese, I cannot tell which stool is the cheese on. To get around it, I added another attribute onto class Cheese, which tells me the stool it is on when added on the stool (method 'add').
Part 4 took me around the whole night to finish. I took a long time writing a method that finds the optimal split for the cheeses. I believe my method optimal_split was not the most efficient, but as long as it works, I am satisfied. I am really thankful that Professor Heap sent us the method for moving cheeses using three stools. I just modified his code so that it can solve the 'tour of four stools' problem. 
Part 5 was relatively easy compare to part 3 and 4. I just had to implement the animation by modifying the code in ManuelController. It only took me an hour to finish it. In general, this assignment was a pretty good experience in working on graphics and recursion.


Introduction to recursion tree & OOP, Recursion(SLOG topic) (Week of Oct. 7th)

This week we technically only have one lesson on Wednesday, because Professor Heap spent some time on going through assignment1. On Wednesday, we learned about recursion tree: all the terminologies and the different method of traversal. Again I found it pretty complicated because we did not go through any example of tree in class. However, I am assuming we do not have to worry too much because we have Thanksgiving holiday on next Monday and term test on next Wednesday. In other words, we probably won't go through any recursion tree structure until the week of 21st.
In Python, an object can contains some sort of data and function. It can be assigned as a variable and passed as a parameter for a function. Objects are usually instance of a class: they are created by class and they have all the attributes and method that the class has. In Object-oriented programming, each object and interact with one another: each object can receive and send information to other objects, as well as processing the data received. One of the advantage of OOP is that class (object) are created in hierarchy, so when you have a complicated system with many different objects, it would be easier to handle. For example, if you want to add a function to the system, it would be easier in OOP compare to the traditional model, where program is seen as a list of tasks to perform.
In python and most of other programming language, recursion is a function that calls upon itself in the definition. It usually has a base case as well or else it would result in infinite recursion (which might make the program crash). Recursion breaks down the problem into sub-problems then combine them together, which in turns simplifies the problem. Recursion is especially useful when a function is defined based on previous terms (eg. Fibonacci sequence). Recursion is powerful because we take advantage of the computer's ability when human brain cannot comprehend to calculate all the value of the function at once. Recursive algorithm is also easy to read and write.


Basic Recursion & Inheritance (Week of Sept 30th)

The last time I took computer science course is in Grade 11. Taking CSC148 is a challenge for me this year; especially I never learned how to use Python! This week we learned more about recursion and test cases. Recursion is still pretty new to me, and on top of list comprehension, I found recursion a pretty hard topic in computer science. When I am working on a question that requires recursion, I usually have the right idea, but I can never implement it in the correct way. I think if I want to master in recursion, I should probably read more examples on the internet, as well as doing more exercise. Hopefully I will get used to recursion after a while.

On the other hand, making test cases is pretty easy! The main concern for me is to pick the right test case; implementing the code for test case isn't too hard. Speaking of which, the exercise for this week is pretty easy too! We have to create classes for some quadrilaterals for part (a) (in which some of them are supposed to inherit attributes and method from superclass). And for (b), we are supposed to write test case for the four quadrilateral classes and see if they works properly. Hopefully I did it fine.