The term test took place this week as scheduled. Although I thought I was fully prepared, it was still quite challenging for me. This test covered trees, recursion and LinkedList all of which are difficult concept in CSC148. I went over those topics thoroughly before the exam, however, it still took me long time to solve a practical problem during the test. Taking recursion as an example, it’s hard to figure out a perfect recursive step since you have to consider all situations that are possible to occur and try to express them in a concise way. I’ll try my best to master those concepts and use them smoothly before the final exam.
Alan.Z's SLOG
2015年3月18日星期三
2015年3月9日星期一
CSC148 SLOG for week8
Busy preparing for the CSC148's term test and another test, so I will update my impression next week. Sorry!
2015年3月1日星期日
CSC148 SLOG for week7
This week I want to make a summary of recursion(and I choose this topic to be graded, thanks).
What is recursion?
Briefly speaking, it’s a function calls itself. As we’ve learned in class, any problem solved by recursion can also be solved by iteration. However, using recursion is a wise choice for some complex problem since it always makes the code shorter.
A simple but representative example of recursion:
def recursion(n):
if n == 1:
return 1
else:
return n * recursion(n - 1)
It’s not difficult to find that this is a function for factorial. The function will automatically call itself until n equals 1 which stops the process of factorial. Since this question is not that hard, we can handle it using while loop, too. But when we facing a complicated question, we may need using loop under loop and, without doubt, it is more likely to make a mistakes. Using recursion, we just need to divide a problem into two parts, basic cases and sub-problems. Basic case is always zero or empty string/list(which is easy to solve) and for the sub-problems, the function calls itself until the basic case occurs. For example, we need recursion when writing functions with nested list. The function will run itself again if it encounter another list and stop when there is no more sub-list, solving the question layer by layer. So recursion is an essential tool for computer scientists when the problem involves an object within another object, such as some Trees question.
Having eliminated the unnecessary code, recursion solves the most problems in an efficient and elegant way. Although it takes some time to grasp this brilliant method, you will find it’s all worthwhile after mastering it.
2015年2月15日星期日
CSC148 SLOG for week6
This week we were asked to make a summary of Object-Oriented Programming(OOP). My first impression on OOP was that it means ‘class’. However, it has a much more formal and detailed definition on wikipedia: Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which are data structures that contain data, often known as attributes; and code, often known as methods. In CSC108, most of time, we were using procedural programming, another paradigm. While procedural programming pays attention to writing procedures(or functions) implement on data, OOP mainly focuses on objects which contain both data and functions.
There are several essential concepts covered by OOP:
Objects: Instances of classes. Simply speaking, it stores properties of a thing in a class to some location.
Class: A blueprint of a program. It’s like to describe something you want in your own way. To make a class, it’s important to form a delicate structure first. Given an ultimate goal, you need to figure out attributes(usually noun) and behaviors(usually verbs) and assign accurate types for them to accomplish your goal in a better way.
Methods: Operations on objects. You can change some of properties of an object through some methods you create by yourself.
Inheritance: Preserve properties. When you are creating a subclass, you can use inheritance to maintain the same properties between superclass and subclass which can simplify your code to some extent.
2015年2月6日星期五
CSC148 SLOG for week5
It has been a month since I took this course and I gradually find it is much more challenging than CSC108. The biggest difference between those two courses is that I need to care about the structure of a program by myself. In CSC108, the professor would give us a single function and inform us what it can do by examples. We just need to write a right code for it. Now, we are given an ultimate goal for a program and we need to make an overall design to make it come true. Although it is more complex, it makes me feel I'm a real programmer.
I took the first term test of CSC148 this Wednesday and I want to make a summary of it. Actually, I made a huge mistake in preparing this test—not checking piazza frequently! I hadn’t attached enough importance to piazza before took this test since I thought I could handle the course material without discussing with others. In fact, I was wrong. Looking through others’ questions and answers to those questions is of great benefit to understanding the course content and preparing for the tests. Without checking piazza, I had no idea what contents would be covered by this term test. Therefore, I reviewed much more than the range of this test and couldn’t focus on the key point of it(for example, I spent lots of time on Abstract Data Types). I didn’t even know we could bring an aid sheet to the exam. Fortunately, questions in this test didn't require me to look an aid sheet for help otherwise I might have freaked out during the test! In a word, I will get used to using piazza as soon as possible and make the best use of it.
2015年1月29日星期四
CSC148 SLOG for week4
It was a tough night. My teammates and I fought for Assignment 1 all night long and finally finished it at 7 this morning. Thank god! We made it! Though I thought it was a torture during that time, I have to admit I’ve learned something critical for mastering computer science through this procedure.
1.Preciseness. Compared with natural language, programming language needs one hundred percent preciseness to make a command. For instance, once we used a method imported from a class we had made. All of us thought we were using it in a ‘proper’ way, but it still raised error when we ran it. Having checked several times, we found the reason. Brackets! We wasted more than twenty minutes just because we forgot to add a pair of brackets after this method’s name. So learning computer science does train us to treat a problem cautiously and precisely.
2.Patience. Without exaggeration, I considered to give up thousands of times during last night. Many times, we thought we had done everything right but it just could not run out successfully. We need to double check again and again in order to find out a little bug, maybe just a pair of brackets. This process sometimes made us feel annoyed and even desperate. I even thought about dropping this course. However, when we clam down digging into the code, we did can find the bug and fix it. The pleasure and sense of achievement we got for the first time running our game successfully was really unforgettable.
3.Teamwork. Many hands make light work. I don’t think I could finish Assignment 1 such ‘perfectly’ without the help from my teammates. They could always come up with some brilliant ideas when I was stuck with difficulties. Thank you guys!
2015年1月25日星期日
CSC148 SLOG for week3
Before today, the word ‘geeks’, in my mind, stood for those people who are talented in coding. So I thought programming might be the only thing they need to care about until I got the topic for this week’s SLOG. Why geeks need to know how to write? With curiosity, I started digging it and was totally shocked by the power of writing in daily language when I learned the success of Linus Torvalds.
There may be thousands of reasons for why geeks need to write. So I will only mention three of them which are most essential in my opinion. First and foremost, writing is one of the most efficient way for communication. It helps programmer to share idea with others and get others’ comments by the same time which may help you to improve your code. Either of them will eventually contributes to the success of program developing. In other words, mastering a programming language makes you ‘talk’ to computers better, but writing in a daily language such as English gives you chance to exchange ideas with people which is far more critical. Just like Joel Spolsky said, ‘The difference between a tolerable programmer and a great programmer is whether they can communicate their ideas’. Secondly, writing also does good to logical thinking. It may sound weird since we always regard writing as arts workers’ task not for computer scientists. However, writing with a good structure to express your idea clearly and persuasively does need logical thinking. Being good at writing, you are able to tell your user what your code can do via an outstanding technical documentation and this is the best way to show the value of your code. Finally, writing is recording. When you look back to those blog or diary you’ve written through learning, it will be like a ‘milestone’ preserving your process from being a rookie to a real ‘geek’. It’s fun, isn’t it?
In a nutshell, writing skill is as important as programming for geeks. Although writing SLOG every week seems a burden to me now, I will try my best to get used to it and finally handle it.
订阅:
博文 (Atom)