Wednesday, January 29, 2014

Week 4

Hello once again, my dearest readers.

Time flies like an arrow, fruit flies like a banana. Here we are already treading through week 4 of the 2014 winter semester. The semester is almost 1/3 over, and it feels almost too calm this week.

Both the exercise and lab this week consisted of writing programs of unittesting and catching errors in input for your code as well as inheritance where a subclass inherits a superclass (lol yay lazy people, who writes new code am I right?). The exercise was slightly challenging at first, but after a thorough reading of the handout and figuring out what the format of this kind of code should be, the program was simple to write. I find these exercises rather enjoyable as they give me hands on experience of how I should write the code. One can understand concepts rather easily, but putting concepts into practice is usually more difficult to accomplish.

Also I wanted to say that the labs are quite nice too, working with a partner is a lot less frustrating than working by yourself to solve a problem sometimes because we have more brains to think. Denise, if you're reading this, I just wanted to tell you you're a great lab partner and I'm glad we're working together! Thanks for pulling me back when I come across mental hurdles and (somehow) completely forget how to write classes because my mind just goes blank.

But this week...it's too calm for a week of computer science, SOMETHING FOUL MUST BE AFOOT!

The calm before the storm (war) named "Recursion", that are like the Dead Army of Dunharrow. We students are like the Orcs who thought we'd win the Battle of Gondor (Recursion) easy peasy because we completely outnumber the enemy (I mean it's only one concept right? Recursion...pfffft.) BUT THEN all of a sudden Aragorn (Danny Heap) will come and summon all these undead soldiers to kill us all.

(Wait so does this mean our professor is the lost King of Recursion?)



Tuesday, January 21, 2014

Object-Oriented Programming (week 3)

Object-oriented programming...

Is a type of programming language where objects are created and methods (functions) are implemented for these objects to do things. The objects are usually created as class instances, and they interact with each other using the methods that programmers implement.

It's truly marvelous, programming. In object-oriented programming, by typing what seems like simple words and phrases alongside a few symbols, programmers are able to create objects in their own instances and make these objects perform tasks as they wish. Sometimes when I'm programming I feel like a god, breathing life into an object as I create a class, commanding it to do whatever I wish by simply typing a few words.

If it were only as simple as that.

Programming in Python, or programming in an object-oriented language may be like breathing life into an object, but this object will rarely ever do as you wish it to on your first try. If you wish it to move left, sometimes it might tell you you're crazy, and that you never implemented a method for it to do so when you have. Then you go back into your code and you realize that you made a typo somewhere in that move_left function. Ah--problem solved. Will the object move left now? 

Maybe. Thorough testing is always needed in programming. If you wanted to write a program that allowed your object to dance, changing your move_left function might completely mess up your move_up function.

This is where debugging comes in. You must fix all the problems to your program through debugging to make it work as you wish.

Debugging is one of the biggest challenges to programming in my opinion. You may take a couple of hours to write your code and putting your ideas down, but it may take days on end to get your code to compile and do exactly as you wish.

I know many fellow students and programmers probably get into this programming zone when they're trying to program something. In this state of mind, anything is possible. It gets 10 minutes to get started, and you're just typing away like a mad(wo)man. It's a logical state of mind where breaking down problems are like a piece of cake. You create and create and create. Then after you're done you try to test the program to see if it works, but lo and behold, there's a billion bugs in there (just kidding, probably quite a few still, but imagine if a program had a billion bugs lol). 



"Take a breather, friend. Go rest your brain. You deserve it."

I always tell myself this after I go on a programming rampage. I find resting the brain a little bit with a quick nap or a little bit of gaming can really help with this. When you come back to the code, you're looking at it with a completely fresh outlook, and now you're starting on your debugging rampage. :)

With extensive testing and tinkering the code, you'll eventually have your beautiful program with fantastic objects that you created and that you are commanding--and you can feel like a god again. YAY YOU! Now time to get some sleep...


Edit: Holy crap the lab this week though. We figured out how to do the efficiency part of the stack for first in first out but for some reason we couldn't figure out a way to implement it so that the run-time would be super fast.