My experience in CSC148 for the first three
weeks was rather relaxing and enjoyable, except the fact that assignment1 is
due in week4 and there is a test coming up next week. The course materials were
pretty straightforward for me, since I had previous programming experience in
Java. However, there are several cool Python features that Java does not have
which have caught my eyes on. In this post, I will briefly explain the concepts
we learned in class and comment on my experience of working on assignment1 with
my group.
The materials we learned in class include
class design, property, inheritance and list comprehension. Let’s begin with
list comprehension, which I find an interesting feature in Python. Basically,
list comprehension is a simple way to shorten your code when implementing a
list involving iterations. It has the general format [<expression> for x
in iterable]. The beauty of list comprehension is that it simplifies your code
into one single line instead of writing every iteration in different line,
which can get really messy especially in a nested loop. Consider this example,
And the result is here
These two implementations produce exactly the
same result, but look at how simple and elegant the fist implementation is. In
fact, I have learned to try to keep my program as simple as possible, because I
think it will benefit me when codes start to get longer and hard to follow.
Now, list comprehension just becomes the handy tool.
Inheritance is the biggest concept that we
practiced using in assignment1. Even though it is not a new concept to me, I
still find it pretty challenging when deciding on the structure of our program.
Inheritance involves grouping common attributes and behaviors in a parent
class, so that every child class can use or modify them without having to
rewrite the common stuff over and over again. For assignment1, my teammates and
I had difficulties on how to implement the game_view class without making it
specific to subtract square. At first, we put a bunch of codes in
if __name__ == ‘__main__’, but later
realized that we need to break down these codes into methods that can work for
every game. Yet, we had no clues how to do it. To overcome this problem, one of
my teammates went to the aid center and I consulted Danny after lecture on
Wednesday. After our attempts to seeking for help, we finally came to
understand the proper way to implement game_view, which uses instances of
game_strategy and game_state.
Overall, my experience of working with my
assignment1 group was delightful and engaging. At first, we decided to each
write a version of the program and improve on the best one out of three. However,
it became difficult and time consuming when you want to improve or work on the
codes that are not written by you, simply because of the differences in
implementation. Even though it took me a long time to understand the codes of
others first and then comment on my opinions, this process provided us with a
variety of ideas and the widest collaboration we can get from each other. I
learned a lot from my teammates and I appreciated their efforts of trying to
make the assignment as good as possible. Yet, I noticed the subjectivity of
this assignment, so I am still unsure about whether or not our implementation
or structure is the ‘correct’ way to tackle this program. Thus, I am anxious to
hearing feedback from the TAs.
Lastly, I want to write a little reflection
for the first quiz I had, which gave me a score of zero. I have to say that I am
surprised by the result, because I consider it a fairly simple exercise. But it
turned out that I did not read the question carefully: the question asked for an __init__ method for the InventoryItem class, but I misinterpreted as asking for
a InventorySystem class. I have learned to be more careful when reading long
questions, since understanding the question is the first step of solving it.
Thanks for reading another long post (can’t
believe I wrote this long lol), I will see you next week!


No comments:
Post a Comment