Monday, April 6, 2015

Week 12: CSC 148 is Finally Over!

Time Flies

It is hard to believe, the whole semester is almost over. And the summer is approaching. But before that, the slog and the final examination is the priority.

Course Events

There are five important course events, in my opinion, including two tests and three assignments. For the first assignment, I did quite carefully and spent a lot of time, because I have never done any programming assignments without a starter code! I did not know exactly what the requirements were. So I changed and changed. I thought it would be difficult to get a high mark. But the result was quite the opposite: 90%! Highest assignment mark I have ever had! Test 1 was almost the same. But test 2 was miserable: I didn't review for anything because I was too confident. I almost failed the test 2! But I still think it is not a bad thing at all: at least I can work extremely hard for the final exam instead of wasting my time playing games because of it.

Hurdles

There were not so many hurdles at the beginning of the course. Inheritance was simple. But later the contents because harder and harder: recursion was one of the most abstract, complicated and fancy concepts I have ever met. Related concepts like linked lists and trees took me hours and hours to do questions in order to familiarize them. I gradually realized the importance of the lab, it have provided me valuable opportunities to practise and sharpen skills in programming due to the strike. Later assignments and tests have not been graded due to the strike. So I decide not to write about them.

Looking Backwards

CSC108 was easy. But 148 is relatively complicated. The difficulty grew geometrically. The professor began to teach new concepts before I started absorbing them. I began to doubt myself whether I am really suitable for learning computer science. Back in high school, I was always the best student in computer-related courses. In CSC108, I began to be overconfident: I believe could still succeed in every task even I did not work hard. Though I got a relatively satisfiable mark in CSC108, I just realize I haven't built a rigid basis for my career in computer science when CSC148 is almost to finish. I began chasing. I have had a few processes though they are still not enough to cover my lost. I have thought about switching to other programs. But I ceased the idea quite soon because being able to program a highly-qualified program is my dream since the first day touching the computer in kindergarten. I cannot quit simply because of a small setback. I must cheer myself up, comprehend everything required to be a professional programmer and build a masterpiece.

Monday, March 30, 2015

Geeks and Writing

Time flies.
It is hard to imagine, the second term is about to end, which also means the first year of university is going to finish. I believe I have grown a lot, both consciously and unconsciously. I was one of the best students in high school and therefore I sometimes looked down upon others. But here, in the university, I meet the people even better than me, much better. I thought it was normal for me to accomplish the assignment in a week (several hours per day). Later I just realize somebody can conquer it in an afternoon! I thought I was one of the most hardworking students on Septemberp, but later I just believe I am one of the laziest. They are far too excellent than me. It reminds me of the first slog I wrote.

WRITING

I used to think all the programmers do not like to speak. They would rather using programs and computers to express their ideas. But I realize I am wrong after a one-year experience with computer science. Actually many programmers are quite talkative and sociable. They talk about their experience in life and programming. What will be the trend of the future technology. Therefore, the stereotype of programmers has changed a lot.

COLLABORATION

After three assignments, I gradually realize the importance of writing more than ever. It is quite difficult to conquer an assignment by a single person, including myself. Taking assignment 3 as an example, we implement each function by each self. After finishing all the functions, we compare each function one by one. We read the comment of each other in order to obtain a better solution between the two. This makes our process quite efficient. As a result, I realize the significance of collaboration.

Sunday, March 22, 2015

Week 9: About the Test and the Strike

The Test and the Strike

Before the test

A test was held on this Wednesday. Then I realized the importance of the lab. I used to think lab was useless: 'Why do we need to go to lab and practise? These are just a waste of time.' But when the date of the test was approaching, I just figured out I did not know anything in the past tests! The questions related to recursion and linked lists seemed easy and adorable in the class, but they suddenly became hard and seemed nonsense after I tried to solve them. I asked my friends and they told me they were in the past labs. 'What if there was a lab!', I complained. I had been extremely lazy so I didn't do the labs assigned during the strike.

During the test

Before finishing the past tests, I thought test 2 had been extremely simple because I finished 60-minute test 1 in 20 minutes and I got 90% several weeks ago. But I found it much more sophisticated in the past tests for test 2. Therefore my confidence decreased almost to 0. As a result, at the beginning of the test, I was stressful and did not know how to do the question. I forgot what 'traverse' means! Then I took a breath and asked the TA who was suppose to be on strike. Then I began tackling these questions. When the 60 minutes passed, I had much confidence.

After the test

I realized I should have done the labs and solved the problem remained in my mind on time. So I did the questions in the lab of week 9 by myself on 7-9 p.m., Thursday, the time that supposed to have a lab. I started to have problems. But there was no TA to help me! I didn't finish until 11:30. And some problems still remained in my mind. I then profoundly realized the importance of the lab and the TA. I hope the strike will end soon.

Sunday, March 15, 2015

Week 8: Frustrated About My Assignment 2

Assignment 2

The Weekend Before

The assignment 2 was due on Thurday night of the eighth week. I didn't officially start writing code until February 28th, the Saturday of the seventh week because I thought it was as easy as assignment 1. But the truth was completely the opposite: I spent the whole weekend on GameState. I was quite confused. How could it be integrated into GameView? And how to make it fit into minimax? These questions had hindered me for the whole weekend.

Monday and Tuesday

When I started on writing code for the strategy Minimax, I found that I even did not know how to start. So I even didn't sleep on Monday morning and became extreme worried. As a result, I even skipped CSC 148 and CSC 165 on Monday morning. Before I slept at 11 a.m., I figured out a helper function is required in Minimax. 
On Tuesday, I went to the office hour. One of the result was that I found out I misunderstood the structure of the game. I used to think that only one state was used in the entire game. Therefore I didn't what could be recursed on. Then I realize every step is a state. And when a new position is placed, a new state is generated which produces recursion. Therefore the mistery was solved.

Wednesday and Thursday

After I figured out what was going wrong, I began to rewrite everything, including GameState, GameView and everything else. 
And I checked the format by pep8 on Thursday.
Finally, I can have a nap safe and sound on Friday.

Monday, March 9, 2015

Week 7: Binary Tree and the Assignment

I decided not to go to the class this week because there would be two assignments due the next week: Assignment 2 for CSC148 and for CSC165. But my friends told me it is a bad habit to skip class even the deadline is approaching since then I don't know what is going on next. So I still learned something new:

Binary Tree

Binary tree is a tree that has only 2 branches: the left and the right. One or both can be None. If both are None, then it is a leaf. And itself is a datum.

Sample questions: how to find the depth of the tree?
We need to use recursion to go through every tree and use max() to compare the length of each node in order to get the greater one.

Binary Search Tree

Binary search tree is a tree that is used to search a set of data quickly. Since it is binary, it also contains only 2 branches: the left and the right. the left one is normally the smaller one while the right one is the greater one. This structure saves half of the time to find a number: if the number is greater than the datum, then it searches the right side of the subtree, or it is less, then it searches the left side. Definitely, if it is equal to the datum, then it is the number we need to find.

About the Assignment

It was much harder than I had expected. I thought it could be conquered in less than 24 hours, but the truth was, even after 48 hours, I was still struggling on the minimax: a game strategy that requires recursion.
So I decided to go to the office hour to ask the professor. He told me something basic yet important: Read the starter code! I had never read the starter code, and therefore it caused a problem when I used the help function. For example, I thought 'apply_move()' could work but it actually did nothing in my code. It didn't update the code automatically, which I expected. After a complete comprehension of the starter code, I changed it into: 'new_state = apply_move()' and I used the new_state to go though the next step. And then it works! It did the function that I expected. So in this lesson, I learn something new: Don't rush to start writing, read the instructions and the start code thoroughly instead.

Sunday, March 1, 2015

Week 7: Recursion: Fanciest Stuff I Have Seen

Week 7: Recursion

First Sight

I can still remember, the professor introduced the idea of 'recursion' several weeks ago. At that time, I thought it was a piece of cake. It reminded me a quite famous story from ancient China: "There was a temple in a mountain. In the temple there were two monks. The senior monk told a story to the junior monk: 'There was a temple in a mountain. In the temple there were two monks. The senior monk told a story to the junior monk: 'There was a temple in a mountain. In the temple there were two monks. The senior monk told a story to the junior monk: ...''". Yes, the story never ends. That's my first sight of recursion: something that repeats and repeats and therefore it never ends. But how is that different from 'while-loop'? Is that a 'while-loop' in a class?? These questions triggered me to keep on struggling on computer science.

Difficulty

'I should have prepared for the lab!', that was what I thought after the lab about recursion. Normally, I didn't need to preview for the contents of the lab. Still, I could comprehend most of the knowledge points hidden in the lab and get a 2/2 in the quiz . But it was the first time I could not finish all the questions in the lab! Even for the first question, I had struggled for a hour (Every lab is 2-hour long.). I only finished half of all the questions and I messed up the quiz! What a shame! I became frustrated and sometimes I even thought computer science was not suitable for me. But I am not the person that give up so easily.

Struggle

I began to listen carefully to every word that the professor was saying. I began to ask questions in the office hours and on Piazza. As a result, I began to comprehend the essence of the recursive functions: Functions that are using and are used by itself. And I found a 'trick' to write recursive functions:

if <first example>: # Usually it checks for the empty case.
    return <the type defined in the function>
else: # The second - last examples fit here.
    <use the function itself: where the recursion goes>
    return <the type defined in the function>

Maybe it is not a trick for somebody. It is simply a stardard format to write recursive functions. But it really helps me a lot.

Epilogue

I become more confident with recursion now. I could easily recognize how the recursion is hidden in the question though some questions still struggle me for a long time. I have boundless thoughts about recursion but I have to finish my assignment about recursions now!

Friday, February 13, 2015

Summary of Object-Oriented Programming Concepts

Concepts of Object-Oriented Programming

Object-Oriented Programming (OOP)

OOP is a programming paradigm that is based on objects, rather than other things, like imperative, declarative.

Object

Object is an instance of a class.

Class

Class is a combination of attributes and methods. It can be pre-defined, or can be written by the programmer.

Subclass

Subclass is a secondary class under the superclass. It inherits all the attributes and methods of the superclass. It can also build it own attributes and methods by overriding the original one.

Upperclass

Upperclass is the parent class of a subclass.

Inheritance

Inheritance (verb: to inherit) means that the subclass can possess all the attributes and methods the superclass have.

Overriding

Overriding (verb: to override) means that the subclass can override some attributes or methods inherited from the upperclass.

Attribute

Attribute defines the property of a class. In python, it is defined in __init__ and attributes are often inserted by parameters.

Initialization in a Class (__init__)

Initialization (verb: to initialize) is where we define the attributes and parameter of a class. It must be defined in a class. In python, it is defined by "__init__" in python.

Self

Self represents the class itself inside a class.

Parameter

Parameter means the variable taken by a class. Parameters always become attributes when initializing.

Argument

Argument is the specific parameter in a class.

String in a Class (__str__)

__str__ returns a string that contains the public face of the class.

Representation in a Class (__repr__)

__repr__ returns a string that contains the exact representation of the class. Sometimes it is same as __str__.

Equivalence in a Class (__eq__)

__eq__ compares whether 2 objects are equal and therefore returns a boolean.

Abstract Data Type (ADT)

ADT is a kind of data type that is abstract.

Recursion

If a function uses itself in the function, then it uses recursion.

Stack

Stack is a class that users can only reach the top of the stack (the last item of the list).

Tree

Tree is a class that has its value and children.

Saturday, February 7, 2015

Mystery Solved: Impressions of Tracing Recursion in week 4

Debutant of Recursion

Although the two assignments of computer science had really messed me up, I became even more stressful at the Monday class of the 4th week. The first thought of recursion was that I was not suitable for learning computer science. I was about to drop the course or even change my major. Though it was a little bit exaggerated, you could still imagine how I felt about it. Recursion was something completely incomprehensible at the first glace. 

Panacea

However, with the introduction of the concept of recursion, the professor had also kindly provided us a piece of sheet for the first time. He started to explain the details, that is, tracing recursion. I began to understand more of recursion, and get confused, and understand more, and get confused, and so on... Wow, how amazing it is!!! Recursion is a function that uses itself in the same function. What a wonderful yet quite effective method!!! Who thought about it? Recursion seems mysterious and infinite to me while tracing is like a panacea in computer science that can help me perceive all the mysteries in recursion.

Afterwards

Recursion is something unbelievable and fascinating in my mind now. It also solves many problems that have lingered in my mind for a long time, exempli gratia, how to get the sum of a list that has countless nested lists. After I was enjoying in tracing all the codes, the fact struck me again... I found it extremely hard to write one by myself! To write one seems much harder than to trace one. How could that happen?? Does that mean I didn't carefully listen to my teacher? No it's not, after going to piazza, a website to ask and answer questions about the courses, I realize it is not required at that point. Yet, I still successfully created one during the laboratory at Thursday night.

Saturday, January 31, 2015

New Semester: My Impression of First Few Weeks

Impression

Finally, I succeeded in CSC108, the most rudimentary course in computer science. So I thought CSC148 would be as easy as the previous course. But the truth proved I was wrong. It was completely the opposite.

First Week

New and fresh, is the first thing I perceived in the first week. I got excited, because I was one step closer to my dream of programming. We learned "stack". I don't exactly remember what else we learned, since I have learned these in CSC108. Therefore I didn't struggle at all in order to understand all these materials. But until the next week, I just realized the first week was simply the basic warm-up.

Second Week

"What the hack is that?" Danny, the professor told us somthing about "inheritance". I have learned what the "class" is, but I believed "inheritance" has nothing to do with it. Along with five other courses, including CSC165, another frustrating computer science course that is irrelevant to programming, I suddenly felt hopeless during the second week.
However, things became better after I took the tutorial at Thursday night. Step by step, I began to understand the significance of "inheritance" and the method to collaborate it with "class" with the help of the TA. Gradually I found it more and more useful, but still, quite difficult.

Third Week

Although I was more confident than in the first two week, the assignment was another big shock for me in the second week. I even didn't have a look at the assignment before the Sunday of the third week. I felt the professor gave us the wrong assignment at first glace. I even didn't know how to start on the project.
Why do we need to keep a course blog(SLOG)? That's the second thing I wanted to complain for the third week. Before writing the SLOG, I thought it was completely irrelevant to programming and it was another way to decrease my mark. Fortunately, I found it quite interesting after finishing my first article: "Why geeks need to know how to write".

Epilogue

A sense of accomplishment and achievement was suddenly in my mind after writing two articles (including this one), though the progress was not so successful - mainly because English is not my first language, maybe even not the second. For some sophisticated phrases, I need to look up in the dictionary, or use google translate, in order to convert from my mother tongue to English. But at least, my writing skill is improving and I feel it is somewhere I can express my own ideas and thoughts.

Thursday, January 22, 2015

Why geeks need to know how to write.

WRITING

Geeks are like us who like computers, in my opionion. We spend most of the time on computers and tend to be insociable since we do not communicate with others very often.  At least it is sometimes hard for me to share my ideas.

COLLABORATION

It is difficult to imagine to build huge, interesting programs by only one person. Nowadays, collaboration is essential to achieve these goals. While writing codes, it is necessary to explain the codes we wrote in order that others, like partners, clients, etc., to understand the code and continue working on it, otherwise it will be just in a mess that nobody is able to follow.

DEBUGGING

It is also helpful for us to keep a debugging blog so that we can see our progress every week, even everyday. The basic skill for this is also quite basic: the writing skill.

IN GENERAL

After writing the sentences above, I just realize it is an interesting to do to write in a slog, which I have never done before.