Wednesday, March 4, 2015

Object-Oriented Programming

As a 'transitioner' from csc108,  Object-Oriented Programming  seems really tedious and unnecessary to me at first. For the Subtract Square game in assignment one, I could totally make the game by just using a bunch of for loops, ifs and user inputs, without touching classes at all. And introducing classes makes the game structure much more complicated, thus much more bugs and errors to fix. 

It was not until assignment 2 that I started to realize the merit of OOP: with a clear and well-defined data structure, it actually prevents bugs and errors. Since as the game gets more complicated,  it's really easy to get lost if the gaming process are not well recorded. All those classes coded by the Professors, such as Game State and Game view provide us with the means to keep track of the entire game and AI's move. 


OOP is like designing the right tools before diving into the problem directly, it might seem a bit of wasting time at the beginning, nevertheless it will definitely offer long term benefits when things get harder. ''Well begun is half done'' Sometimes choosing the right way is more important than starting to deal with the problem right way. 

Tracing Recursion --- to be graded

Recursion is something I have never touched before, it is mind-blowing in a sense that it allows us to execute an arbitrary amount(i.e. just the right amount ) of commands according to the problem. Instead of tackling one specific case of the problem, recursion serves as a generic formula, whose power lies in the possibility of defining an infinite amount of objects with only a finite number of lines of codes. It is particularly mighty in a way that it automatically adjusts the amount of code needed to solve the problem. Human intelligence is embodied by the infinity achieved by 'finity'. 

Tracing is already confusing enough, yet it is only a piece of cake compare to actually writing your own recursion. It all started after the introduction of tree ; not only we have to tackle with the confusing enough tree structure, but also its entanglement with recursion.   At the beginning, I was more or less 'trying' to make the recursion work by keeping typing some random code similar to the example, instead of actually having the whole idea of knowing how to do this in my head. 

Well, "No pain No gain", "Pain is temporary, GPA is forever", although recursion really is really hurting my brain, but these are extremely good mental working out which will definitely benefit me in other aspects of life. Logic, persistence and resilience are the ever-lasting virtues, triumph will always belong to human's mind.