Friday, January 31, 2014

Finding and fixing problems

In this week, working on computer science becomes more and more interesting. Our lectures, exercises and labs all improve my programming skills and let me understand well. 
 
First of all, I want to talk about my exercise2 which help me to practice using the Exception. In my opinion, ‘Exception’ is that we can except when something happens, the function will raise a error to help you figure out what kind of error your function makes. In the exercise2, I fixed a mistake for long time. I raise a ValueError when x cannot be convert to a integer with int(x) if x is a str. But actually we do not need to raise that because python can raise that error itself. Therefore, next time, I really need to read the handout carefully. And the next thing is the order of our exceptions. Before the exercise, I think the order of the if loop cannot influence the result. However, I fail a test in my e2b but my function has only one difference with others who pass the test. I did not find my error, but my partner helped me find that. He tested if the order can influence the result, and it worded. Therefore, I fixed this problem. I also think that let other people help you figure out your mistake is a good choice. Because sometimes people cannot see the error in their own works. 
 
Secondly, for my lab, it really goes on well. This is the first time I try to use unittest to test our function by ourselves. I and my partner at first thought our works are perfect. After testing it, we caught many error in it. Hence it is very important for us to learn to test by ourselves before someone else help you to find the mistakes. 
 
The most important thing I learned this week is that finding and fixing the problems. I think it really helps me in my computer science study.
 

Wednesday, January 22, 2014

Object-oriented programming

Our topic for the first journal is Object-oriented programming. After I saw this title, I asked myself that what is the Object-oriented programming? What I learned about Object-oriented programming in the lectures? What the Object-oriented programming do? 
I do not want to talk about the definition of Object-oriented programming in my slog. I just want to describe my opinion about it.
First of all, personally, I think class is something contains the characteristics of an object. For example, there is a class Dog. It maybe contains the gender or the color of hair of dogs. What information the class contains depends on what I want it to contains. 
For example, my class Dog is shown as follow:
Class Dog:
    Def __init___(self)
    Self.color = color
    Self.gender = gender
There also can be some methods in the class. If you want a dog who is a girl dog, you can create a method to see if it is girl. It will be seems like this:
Def gender(self, gender):
Return self.gender == female
In my opinion, we can store the information in our class and create methods to do everything we want it to do with the given information.