2015年1月29日星期四

Things from these weeks, and also about assignment 1 and the recursions.

CSC148 started scarily, especially with its scary assignment 1.
To be honest, class was the part which I didn't really understand during CSC108H, so designing classes was really a challenge.
But after a few weeks of study, I think I have a way better understanding on classes than before. Therefore, I do hope do get a nice mark on my first assignment. XD



Recursion
Recursion is a function(or maybe later a method, but anyway a way of doing things, i will always refer it as 'function' in the rest of this post) which calls itself.
When we use recursion:
1. when we can solve a big problem by solving its components using with the same concept.
2. especially when we don't know how many times we need to call the function. (We don't know how deep we need to go.)

the typical appearance of a recursion is:
def f(L): #f is a program and L is the input
    if  isinstance(L,x): #x refers to a type, it could be anything.
        #thing here could vary, but anyway it calls f on the components of L.
    else:
        return XXX #return the basic value of this function.


Things from assignment 1:
- doctest doesn't test on print or input, so need to be careful for some potential mistake there.
- when printing, the white space due to indention will be printed as well, what I did to solve this problem is to delete the indention.

why geeks should write?

Well, geeks should write, not to eulogize the beauty of the life or the glory of the world, but to, for most of the time, build a better understanding of computer science.
Writing is good to keep track of what happened. Writing down the coding experience is helpful for future coding process. After recording down a bug we found in our codes, we have the reference source to look at when next time encountering the similar type of bugs.
Writing is also a good way to recollect the material that we have learned already, in another word, it’s a good way of reviewing. We don’t learn stuff by just going through it once; however, going through the same thing over and over again seems too boring. By writing, we can achieve a good understanding of the materials that we learned.
There is a Chinese old saying known as people gain new insight through reviewing old materials. By writing, we are organizing the old materials in a way such that it’s convenient to come back in the future. After writing down the expiration from the current materials, we should often go back to what we wrote previously so we may gain something new from it.

Anyway, even we were just geeks, we still should write. Geeks write to keep track of what happened, and to prepare for what will happen.