A tree? Oh, like one of those tree diagrams! That sounds easy to make. Oh, wait. It's not.
At first it seemed like planting and taking care of a real tree would've been easier than learning about trees in Python and recursive methods to make them work. I definitely felt unprepared when I went to my tutorial to get stuck on a question about trees for the whole class. Although I had a lot of trouble grasping the concept of class objects inside other objects of the same class, I decided then and there that trees would not be the end of my programming career. I refused to get defeated by what seems like a simple concept.
You can think of a tree like an elongated list of lists. There is one list that keeps track of other lists (which may or may not keep track of even more lists). This main list and all the other sublists have values that are associated with them. So in a way, trees have more functionality than a list of list of list of etc. Sure, that is not too hard to understand. This is not where I struggled.
The hardest part of trees is the methods that you can implement with them. For example, you can create a method that finds the highest value in the tree. In short, there is a method that searches every node of the tree and returns the highest value among all the nodes. Methods like these are what make trees really tricky. You cannot simply return a max function and get the highest value. Instead, you have to use recursion to search through every node starting from the root all the way to the last leaf. Talk about a whole lot of work.
Sure, implementing this method is not a one-way thing. It is not as simple as plugging in a function and getting the result. But then again, this is exactly what I asked for in my previous posts: I want this course to challenge me with concepts that are not straight-forward. As I take time to better myself in these recursive methods, I will become a better programmer (and in return a better man).
Saturday, February 28, 2015
Saturday, February 14, 2015
Getting Oriented with Objects: Object Oriented Programming
Back before I started programming, I used to think that programmers would write very long lines of code to create their programs. Old me used to believe that the people who make video games have thousands and thousands of lines that make the game. Well, a part of this is true. There ARE many lines of code that make up games. However, as my old self would have believed, they are not all on the same file.
Before I knew what object oriented programming was, I thought that all methods, functions and systems all fit into one file and class. Oh boy, was I so wrong. I am very glad to be wrong, too. If programming like this were the case, I would've given up ages ago. Thanks to the genius that is creating classes and subclasses that work with each other, I am able to create elaborate projects piece by piece. I do not have to focus entirely on the whole picture and instead concentrate on what a certain part of the program does and how to implement it.
How easy is it that I can create a separate file for a subclass of a computer strategy system? I do not have to mesh a bunch of different strategies in the same file but instead I can organize each different strategy in a subclass that is separate from the rest. It makes thinking about computer strategies a whole lot easier. Through object oriented programming, I can mark common features of each specific strategy and implement that in the parent class. Then I can put specific traits of each unique strategy in a subclass. These two classes would then work together to implement said strategy in a game. This kind of orientation of codes ensures that I have an organized setup that I can easily analyze and fix later on.
It may seem like such a simple concept but without it our lives would be a whole lot more difficult. Via object oriented programming, I am one step closer to becoming a master programmer. Well, at least I will have the organization skills of one.
Before I knew what object oriented programming was, I thought that all methods, functions and systems all fit into one file and class. Oh boy, was I so wrong. I am very glad to be wrong, too. If programming like this were the case, I would've given up ages ago. Thanks to the genius that is creating classes and subclasses that work with each other, I am able to create elaborate projects piece by piece. I do not have to focus entirely on the whole picture and instead concentrate on what a certain part of the program does and how to implement it.
How easy is it that I can create a separate file for a subclass of a computer strategy system? I do not have to mesh a bunch of different strategies in the same file but instead I can organize each different strategy in a subclass that is separate from the rest. It makes thinking about computer strategies a whole lot easier. Through object oriented programming, I can mark common features of each specific strategy and implement that in the parent class. Then I can put specific traits of each unique strategy in a subclass. These two classes would then work together to implement said strategy in a game. This kind of orientation of codes ensures that I have an organized setup that I can easily analyze and fix later on.
It may seem like such a simple concept but without it our lives would be a whole lot more difficult. Via object oriented programming, I am one step closer to becoming a master programmer. Well, at least I will have the organization skills of one.
Thursday, February 5, 2015
The Recurseption
Slow down; can you say that again? A function within the same function within the same function? If you were to tell me at the beginning of the semester that you could have a function that calls itself then I wouldn't have believed you. In fact, I sometimes still can't grasp the concept that there are functions that call itself repeatedly. How is it that you can write a function whose steps are dependent on itself? It was hard for me to wrap my head around this concept for quite a while.
It is handy, however, to have friends who are in the computer science field. One friend of mine called Matt brought me into the light that is recursions (he also gave me other helpful tips, such as my personal favorite "try googling it"). He told me to think of how factorials such as "5!" work. You are presented, literally, with a number and an exclamation mark. (At this point, I saw little of how this rationalization of factorials would help me understand recursion any better.) Then he told me to look at the number separate from the exclamation mark. If the number is not 1, then you multiply the number with the factorial of that number minus one. That would look something like this: (5 * 4!).
Woah, hold on a second. There it is! A factorial is inside the same factorial function! Lo and behold, I witnessed the genius of recursions right before my eyes. I finally figured out that recursions are not indeed endless loops that break the paradigms of the universe but actually a two-step process. If a value does not meet its requirements then you implement a change to the value and check for its requirements again. If it does meet the requirements then you return whatever value you need to. It's so simple yet why was it so difficult for me to figure out?
Through the help of my friends (and my ability to grasp my friends' knowledge) I was able to understand the seemingly impossible. No longer did recursions seem to me like a paradox, similar to the idea that someone can travel back in time to meet their former selves. Now that I realize that there are no loopholes in the theory of recursion, I feel like I can do the impossible. Maybe I should consider figuring out time travel now.
It is handy, however, to have friends who are in the computer science field. One friend of mine called Matt brought me into the light that is recursions (he also gave me other helpful tips, such as my personal favorite "try googling it"). He told me to think of how factorials such as "5!" work. You are presented, literally, with a number and an exclamation mark. (At this point, I saw little of how this rationalization of factorials would help me understand recursion any better.) Then he told me to look at the number separate from the exclamation mark. If the number is not 1, then you multiply the number with the factorial of that number minus one. That would look something like this: (5 * 4!).
Woah, hold on a second. There it is! A factorial is inside the same factorial function! Lo and behold, I witnessed the genius of recursions right before my eyes. I finally figured out that recursions are not indeed endless loops that break the paradigms of the universe but actually a two-step process. If a value does not meet its requirements then you implement a change to the value and check for its requirements again. If it does meet the requirements then you return whatever value you need to. It's so simple yet why was it so difficult for me to figure out?
Through the help of my friends (and my ability to grasp my friends' knowledge) I was able to understand the seemingly impossible. No longer did recursions seem to me like a paradox, similar to the idea that someone can travel back in time to meet their former selves. Now that I realize that there are no loopholes in the theory of recursion, I feel like I can do the impossible. Maybe I should consider figuring out time travel now.
Friday, January 30, 2015
First Few Weeks of CSC148
I knew that this course was going to be a whole lot harder than its prerequisite course CSC108. I'm just surprised that this idea didn't cross my mind until I read the instructions for my first assignment. Then again, this was totally expected. I mean, it IS the next course so by that logic it should be harder. Not too surprised, overall.
As I said before, the course material in CSC148 is definitely harder. Back in the CSC108 days, I used to write a couple of methods for an assignment. However, this course expects you to write methods intuitively. By now, I can write the functions I wrote for CSC108 assignments on the back of my hand. Thus, actually writing classes and subclasses seems like a proper step up from where I was before.
Is it strange that I actually enjoy the added difficulty in this course? Maybe CSC108 was too easy. In my opinion, the concepts that I learned in CSC108 was very basic. The material seemed very linear in its practicality and thus I did not feel like the master computer programmer that I aspired to be. But now, this level up in challenge has me questioning whether I truly am a master programmer. The answer is: not yet. But soon.
Sunday, January 25, 2015
Geeks Need to Write in a Language other than Python
When one pictures a computer scientist, he or she imagines a
person who writes programs very well and is knowledgeable in mathematics. One
of the last things that come to mind when picturing an expert in computer
science, a so-called “geek”, is his or her proficiency in writing in the
English language.
Wait, what? Why on earth would a person who knows how to
write in Python, Java, C++, and a bunch of other computing languages need to
know how to write a convincing essay? It is true that many geeks need not write
argumentative essays or research papers on a daily basis. It makes sense to
think that a geek does not require a Bachelor of Arts to write code for the next
equivalent of Flappy Bird. Then why do I
need to write well in English to pursue my career in the computer science
field? According to this logic, I don’t need writing skills to make money off
making programs like Flappy Bird. While that is true, you have to keep in mind
that Dong Nguyen, the developer of Flappy Bird, got extremely lucky with his success.
That kind of luck is not guaranteed for me, you or any other geek you know. So,
listen up; if you want to succeed as a geek, you have to know how to write.
Not many people realize that writing is a skill that is
applicable in not only arts programs. Computer scientists, engineers, medical
scientists: they all know how to write as well. Writing teaches you not only
how to put words into sentences but also how to communicate clearly your
thoughts to another person. Writing helps you put everything in your head clearly
explained on paper (or computer screen) in a language that people can
understand.
Let’s face it; there are few people that can read through a
code that you write in Python and understand fully the intentions of the code.
It could be the most brilliant code in the world and yet it is useless if
people don’t understand how it works. If you add some comments in your code (in
English, most likely) then your code may be easier to understand for the novice
programmer. Still, your documented codes will still be hard to understand for
the layman. Even a geek with Python experience will have trouble reading your
code if it is not well-documented.
If this person doesn't know what your code does, then why
would he consider using it? If you were to show your code to others, you have
to explain what your code does and how it is applicable in different
situations. If you cannot explain this in English then no one would know how
your code works or how to improve it. Unreadable code does not help anyone and
is a detriment of effective teamwork.
In general, programming languages are not the best languages
to communicate with others. There is a reason people in Toronto speak English
instead of Python. Although programming languages have a lot of flexibility and
power, English is still the go-to means of communication around here. There are
many other reasons I can list to prove that geeks should know how to write, but
I won’t exhaust myself with that job. I believe that I have articulated well
the importance of proficiency in writing in the computer science department.
Subscribe to:
Posts (Atom)