Wednesday, 29 January 2014

Week4

    This week we started by discussing the upcoming Assignment 1.  Apparently, it's going to be pretty challenging, but, it won't be fun otherwise.  I'm probably starting this assignment soon, and will update my progress on here next week! 
    During the lectures, we dug deeper into the concept of recursion.  The key to understand this concept is to trace the function.  One layer by another, trace the function with absolute patience.  Another tip is to do the tracing by hand!  Try to write down every step of the recursion.  By practicing like this, you will certainly have a much better understanding of what is happening in recursion.  We did another very cool thing, which is drawing with turtles. Well, maybe you don't agree with me. But, at least for me, I think it's pretty interesting to see how people draw back then with these simplest tools. 

    This week I also took some time to review the final question of Lab 2.  Basically, it was about popping items from the front of a list without shifting the indices.  The answers I got are all telling me to track the indices and go through the list without actually deleting any items.  I found these answers unacceptable, because they are not doing what the question is asking for -- deleting items without shifting indices. 
    However, I also can't think of a satisfying solution to this question.  The closest I got is to replace the items in the list with some distinct values ("None" in my case) and delete these values when evaluating the list.  As expected, this approach gives me the ideal timing in testing.  But I don't think this is the legit way to solve this problem (as I'm also not deleting items at the first place).  I wonder how this problem could be solved... 

Wednesday, 22 January 2014

Week3

    Object-Oriented Programming.

    The concept of an "object" makes this programming paradigm different from others, such as procedural programming. An object could be defined as an element, which consists of contents and attributes, in a program. In python terms, an object is simply an instance of classes. To visualize this conceptual idea, you can imagine an apple tree. Anything grows on the tree is an "object", such as apples and leaves. These "objects" belong to the tree, which could be described as a "class". The colors of those apples and leaves can be seen as their attributes. With its unique feature of object orientation, Object-Oriented Programming enables programmers to focus on the construction of data type and storage, rather than the functionality of codes.

--------------------------------------------
    My thoughts of the week.

    For the past three weeks, CSC148 has been a very interesting class, at least to me. To put my thought of it into one line, it would be: It's familiar yet unfamiliar. Why do I say that? Well, I feel that most of the things we've learnt so far are from CSC108, but were taught in a quite different way. For example, the whole concepts of ADTs and stack are basically reiterating the concept of the basic types, such as list. Technically, they shouldn't be hard to learn. We are just thinking about their data structures more rigorously. (e.g. Do we want to pop the item from the end or from the front?) 

    This week we started to learn some new stuff! We looked more deeply into Stack, which requires the combined knowledge of class and list. We learnt inheritance, exception, and recursion. Inheritance sounds like a fairly powerful feature in Python. But maybe it's because we haven't do much practices on this, so I cannot fully understand its capacity yet. I notice one other point that the professor keeps mentioning in class. That is, the way to update your codes, 
after they have been published, to your clients. It's still quite an abstract idea to me as we haven't seen any real world example. 

    These are my thoughts of the week. Looking forward to the upcoming week! :)