Friday, January 31, 2014

W4: Recursion... Uhh, What?

In the outline for SLOGs, it says that we'll be writing a post in recursion week 7. Honestly, right now I can't imagine understanding recursion enough to write a full out post on it.

Underneath the topic listings, there were the suggestions for weekly blog posts:


And I will easily answer questions several of the questions right here:
Something new I learned this week? That would be recursion.
What's something that frustrated me this week? Again, recursion.
How confident do you feel about material covered this week? Nil. Zilch. Not at all confident. AT ALL.
What was one of your achievements this week? I have had no achievements.
Ask, and then answer, some question you had about course content? I would if I knew enough about the topic to ask questions...
All jokes aside however, I am rather worried by recursion. By the professor's lengthy praise for the topic, I can tell that recursion is a major tool in the computer programming toolbox, and I'd better learn it fast.

While I understand the human process of going through a nested list and counting, I found it difficult at first to follow the prof's instructions on tracing. My first few tries at tracing, I traced every step to the bottom before I could condense the steps at the top-level.

EDIT: I've looked again at the code from lecture (depth of nested list, maximum in a nested list) which completely befuddled me in class. It helps, I find, to copy and paste the code into Python and try to understand each part of the code. Especially with the ternary if statements (which I am horrible at), it's useful to attempt to rewrite the function. If my rewritten function is faulty, I can look at the differences in code and eventually learn why each part is important.

Monday, January 27, 2014

W3: E2, A1, Help Me

This week I have three assignments and one test.
Next week I have two assignments, two quizzes and one test.
Not to mention it's a math test, which means I'm screwed.
If I was smart and learned from my past mistakes,
I would start E2 for 148 today.
Like, now.
If I wanted to be really smart I could start A1,
Especially since I didn't understand a word
Of what the prof mentioned about it in class.

But I have no motivation.
Help me.

Sunday, January 26, 2014

W3: What is Object-Oriented Programming?

When I first heard the term “object-oriented programming” last semester in CSC108, I was confused as to what it meant and how it differed from the programming we had mostly been using thus far.

Over the winter break, I promised myself that I would review classes and be clear on the meaning of this phrase as it obviously would be important in the future. Alas, my self-discipline has never been strong and when the spring semester began I already felt behind.

Thankfully, the first reading posted for CSC148 explained object-oriented programming extremely clearly, even for a beginner like me. As opposed to procedural programming that creates functions to operate on data, object-oriented programming makes it easier to manage complex computer systems by creating objects in which both data and functionality are contained.

At first, this seemed like a small difference, but now after more exposure to object-oriented programming, I’m surprised at how significant this difference is. By defining objects and the methods that operate on them, a program better correlates with how humans mentally think about the world. In class, when we practiced reading a paragraph and recognizing a class, its attributes and methods, I was pleased at how methodical it was to translate the words into the outline of a computer program.

The example in lecture (class Point) was a concrete data type where the professor defined how it was to be implemented. However, abstract data types (or ADTs) which do not specify implementation – only operations and what they do – are useful because they can be written once and then stored in libraries for the use of many programmers in many different ways.

In lecture, I felt like I was doing a semi-good job of keeping up with the theory behind object-oriented programming, but when it came around to tutorials I was obviously lacking in my application skills. On the second lab day, the end of the exercise was to try and find a solution to make class Queue run faster. Although my partner and I got the solution, I still had to go home and think about it before I was clear on how the solution worked.

Likewise, I’m feeling frustrated with understanding inheritance. In one of the readings, inheritance is described as “the evil forest”. More specifically, it is when an object or class is based off another object or class. Thus, it allows for the reuse of code. For example, in class the IntStack subclass inherits from the Stack class but has been modified so that only integers can be pushed onto an IntStack.

On the other hand, inheritance can be a dangerous thing if it becomes too complex. With inheritance, the computer always checks for code in the subclass first and thus it’s possible for some code to never be executed depending on where it is placed. In lecture, the professor demonstrated this using Exceptions.

Although I did as recommended and played around with the code that was uploaded on the CSC148 site, I am still confused with what “try” and “except” mean. There are many variables to fool with (the order of the code, commenting, uncommenting, and “raise”) that I’m feeling lost with what the code means. Tomorrow in class, I will have to ask the professor to reiterate and clarify his words regarding inheritance.

Overall, three weeks in, I’m not feeling as behind as I thought I would – and I suppose this is a good thing – but at the same time I’m certainly lazy and dragging my feet regarding solidifying this new knowledge. Although the new material is interesting, I have to remember to review my old notes as well (and perhaps even rewrite them in the Python 3 format to familiarize myself with it). I also feel like I've been only skim reading the last assigned readings, thus leaving holes in my understanding of certain concepts, especially Exceptions and composition. Before the course moves on, I have to thoroughly review these readings.

Monday, January 20, 2014

W3: Property Control

This past week, we focused a great deal about property control in class. At first, being a new CS student I didn't understand why this was an important issue at all... not to mention I also didn't understand the professor's references to other programming languages as I've never worked with anything other than Python.

Consequently, I ended up doing a lot of at-home reading and research. First thing I realized: the "Code Like a Pythonista" link on the course website is not useful unless you like to torture yourself. In general, lengthy readings do nothing for my learning in CS. I've discovered that I just have to jump right into trying to solve a problem, and then go to the readings afterwards if I have difficulty articulating my ideas to myself. (I found that http://tomayko.com/writings/getters-setters-fuxors, which the prof posted online, was very helpful though. Scroll until you reach the section on getters in setters in Python, however.)

A major aspect in computer science is object oriented programming, which is basically creating classes in code that represent "objects" which can have methods performed on them. Objects have attributes which are what allow a programmer to manipulate said object.

In computer programming, somebody who knows how to find their way into the guts of a program has all the power. Consequently, the original coder uses property control to protect their ideas and intentions. A analogy would be something like the mail-slot in a door. Envelopes can be slipped in, but from the outside it is impossible to retrieve and/or change the mail.

Property control is somewhat the same. As a coder, you make it so that once an object's attributes are set, they cannot be changed and only viewed. Furthermore, they can be read without having to use the polite underscore prefix, for example: "attribute_name" instead of "_attribute_name." 

This is thanks to getters and setters. Although I won't get into the nitty-gritty of coding getters and setters, a getter is basically a function that returns the value of said attribute. A setter, on the other hand, is what the program looks at when someone tries to set an attribute. If the attribute has yet to be determined, the setter allows an outsider to do so. However, if the attribute value already exists, the program firmly rejects any changes.

While I see the important of property control, oddly enough we seem to have completely ignored it after learning it. Perhaps it's more important in actual client code, rather than assignments we submit for CSC148? 

Saturday, January 18, 2014

W2: Greetings

Dear the worldwide web,

This is my first time as a blogger (or slogger) amongst you, so forgive me for any mishaps I may have as I test out Google's snazzy web-publishing tool. So far, so good (I admit to being immediately, slightly obsessed with the various design options, and made this post to see how my blog would look).

For anybody who came across my blog looking for content, feel free to ignore this post (but if you're reading this, that may be too late).