2015年2月17日星期二

Week 6

 This week, we get our feedback of Assignment 1 and Term Test 1.

  Before we learned recursion, we focused on object – oriented programming, and assignment 1 was all about it. To be honest, I am a little bit proud of myself. We learned how to develop a class in CSC108, but we didn't have a chance to write our own classes. After finishing assignment 1, I get the whole idea of object – oriented programming. When programming, you must have a whole picture of what you want. Take Assignment 1 for example, you want a program from which you can choose many different games to play. First, you need generic class for both GameState and GameStrategy and a GameView class for people to play with. Then, develop subclasses piece by piece according to those generic classes until you meet all requirements. I think the key concept is: don’t start form details but start from structure.


  Still, I encountered a lot of problems when doing Assignment 1. I didn't know what to put in the parent classes. Details were undecided so I couldn't write any code including details. Everything must be generic. And I thought the parent classes are useless because they were so generic and simple that I still need to write many specific code in the subclasses. But then I understood, writing parent classes would make it easier to write subclasses because you don’t need to repeat code you already wrote if the subclass requires a method which does the same thing that the method in parent class does. And you will know what you need to implement clearly because you already built the structure when you wrote the parent classes. 

2015年2月8日星期日

Week 5


Tracing recursion can be very tricky. Last week in quiz, we were asked to trace a count_element function. I traced it like this:

Trace ce([15, [3, [5, 19], 32], 17])
--> sum([1, sum([ce([3, [5, 19], 32])]), 1])
--> sum([1, sum([1, sum([ce([5, 19]]), 1]), 1)])
--> sum([1, sum([1, sum([1, 1]), 1]), 1])
--> sum([1, 4, 1])
--> 6

It's really hard to imagine every step of recursion, I got a headache every time I finished a question.
This week Ta told me it's fine to just write the value, like this:

Trace ce([15, [3, [5, 19], 32], 17])
--> sum([1, 4 ,1])
--> 6

This is so much easier. But mistakes can be made easily if we don't trace it step by step and fully understand the recursion, just like my classmate @samnzhang did in the quiz, he wrote:

Trace ce([15, [3, [5, 19], 32], 17])
--> sum([1, 1, 1, 1, 1, 1])
--> 6

This is not how recursion works. The function didn't turn all elements into 1 at same time, it did so step by step.

We also had the term test 1 this week. For me the test is pretty doable. But I spent a lot of time on writing docstring. The reason I lost time on writing docstring is when I was doing assignment or labs, I tended to write code first, and then write the docstring after all needed code were written. If I don't need to hand in the code, or show it to anyone, I just didn't write docstring. From now on I need to write more docstring to be familiar with them.
This week in lecture, we covered a qucik sort algorithm. It was hard to trace at first, I spend a lot of time on it. Recursion can really make the algorithm very efficient.

2015年2月1日星期日

Week 4

The biggest challenge this week is assignment 1. 
Before this week, my partners and I had read the assignment handout over and over again, but had no idea what to do. For me, the only thing I knew how to write was the specific subtract square game part and the game view part. There was so many information in the handout. 
Then I started to look through Piazza. The discussions on Piazza really gave me great help. I remember there was one post about how to start on assignment 1 and how to read the handout. There was many posts about at least how many class should we have. And there was many posts explaining every detail of this assignment. I finally realized the power of discuss. My group got countless help from Piazza. I hope I will be able to answer questions on Piazza when assignment 2 come. Now I know the importance of discussion and sharing ideas.
The other important thing was we finally talked about recursion in class this week. I've heard so much of recursion. I know it's a very important part of computer programming. We just started a little bit on recursion, and I didn't find it very hard so far. I know things can get really difficult when it comes to recursion, so I did my best to understand everything we talked about in class. 
Two important thing this week: power of discuss and recursion.