Sunday, 1 February 2015

Week4: A totally new method to write function:recursion and a week for assignment1

This week is nearly a week for CSC148 as the main topic for the whole week is to work out the assignment 1, and during this week we also learned a new method to write function: recursion.

The assignment 1 makes me have a better understanding of creating a new class. 

First, I began to understand why we should implement some special method. At the beginning, I can not understand why should we write something like __str__, __repr__ and __eq__, but during the assignment 1, I found myself easy to get confused when working on an object. An object is abstract, so we must write something to description it, like __str__ and __repr__, __eq__ also helps us to keep track of the object by differentiating different objects.

Second, I get to know how a game should be like. We create some objects to keep track of some data we need, and we should write a method for the class to help it transfer these data into some actions. In this way, we can make a game or something else.

We were also exposed to recursion this week. I had heard it from my friend before, and I thought it was a magic, I thought it was a special grammar for programming. But now I have some new understanding on it. Now I think it is not a real magic, it's just about using the programming language wisely, and now I think it is not so special, as it in fact doesn't contradict with what we learned before at all! I think a recursion is to repeat use the function over and over again and when it reaches its base case, it will work just as a non-recursion function. So tracing back is really a good way to understand recursion. It is just like the proof by induction in math, it is about using the base case to get to our destination.

No comments:

Post a Comment