Saturday, January 31, 2015

week 4 , my impression of first few weeks

In first week and second week,we talked about object-oriented programming. It was not a hard topic for me, because I had just finished CSC108 and we had known what was class, how to write "__init__", "__str__". I got confused with method "__repr__". I didn't know the difference between it and "__str__". But now, after going through assignment one and consulted some materials, I understand "repr" is a method which returns a string that can construct an object with the same value. It represents a string for computer itself rather than people and "__str__" is designed for people.

Also, "self" was very trick for me. But I decided not to understand but to remember it! For every method in a class, remember writting "self"!!!

In third week, we started to talk about inheritance,we wrote subclass and let them inherit methods from super class.


I like the example which we talked in the class so I post here and I should remember how to write a subclass.

















NOTICE that we inherit "__init__" from super class!



And this week, we started to talk about recursion! I heard about it when I was a senior high school student and I will post my impression for recursion next week.

Thursday, January 22, 2015

week3: why geeks should write

In this semester , I will keep posting SLOG for CSC148 every week.

The first topic is : why geeks should write. 

As we use writing skills in our daily life. The first word which comes to my mind is “record”. People write in order to record their ideas, remind themselves what is important.


Secondly , we write something for the purpose of communication. For example, we write down our programs so that others can understand what we want to do. At the same time, we can write programs in order to communicate with computer. If I write “1+1” in python shell, my computer knows I want to do some easy addition.In a word, writing is an essential and important skill in modern society.

Particularly, writing plays an important role in debugging! In fact, I used to form an algorithm in my mind before starting writing a program. Usually this can't run at first. Only when I wrote my code down, I can run debugging program and figure what's wrong with my code!