(Note to grader: There is now an entry for each week we were meant to post, including a post for each mandatory topic)
Overall, this course was extremely enjoyable! The instructors were fantastic and the assignments were a lot of fun. I've taken courses in a number of different disciplines and in my opinion Computer Science assignments are the most fun. In particular I felt like I could really express myself creatively. I also really like how you end up with something that is tangible (at least relative to subjects like math or philosophy) and that can preform interesting or useful tasks. Out of everything that we had to code for this class, TippyGameState was my favourite. I thought that the problem of how to detect a tippy on the board had just the right level of difficulty and allowed for many different creative approaches. It was so satisfying to see my implementation pass all of the testing I subjected it to. I also really enjoyed working on all assignments on my own, but apparently that will have to change in future CS courses. I suppose I'll just have to adapt.
This course has filled me with excitement for the future. I started programming less than a year ago when my previous career plans didn't turn out as anticipated. I knew I liked logic and math so I thought why not give computer programming a try. I got my hands on the CSC108 textbook and worked through it over the summer. Ever since creating my first functions and my first loops, I've felt an extremely strong affinity for computer programming. The enjoyment I've experienced in this course has only reinforced my feeling that I was meant for this.
SLOG Fulfilment Blog
Saturday, 4 April 2015
Revisit
I've been browsing through the SLOG directory on the course website and I've noticed that recursion has come up quite a few times as people look back and examine their previous posts. This is not surprising since recursion has been one of the focal points of this course. In an earlier post (week 5: tracing recursion) I claimed that recursion was being introduced too slowly. We started out tracing the simplest recursive code for what felt like quite some time before we actually started writing recursive code. Although I still agree that I was ready to jump right into more difficult recursion problems, from reading other student's SLOGs, I can tell that the instructors made the right decision easing us into this topic. Many people reported either that the time spent tracing was extremely useful or that recursion is still a bit of a mystery to them (I know we are supposed to link directly to other students SLOGs in this post, but I think that to do so would be in poor taste given the point I'm making). Therefore the gradual introduction was definitely appropriate even though I felt it was a bit boring. Since I know I'm not alone in feeling this way, maybe there should be an alternate version of this course, like how CSC240 is an alternate to CSC165\236.
Thursday, 19 March 2015
Week 9: Test 2
I've tried to make a habit of, after writing a test, analysing what went right and what went wrong. Overall the test ended up being exactly what I expected and I'm confident that I did well. I studied the right topics and I had a good understanding of everything I studied. As for what went wrong, at first I did not properly read what the last question was asking for. It asked us to write the body of a method that inserts a new node in between the second last and the last node of a linked list as well as change the value of the last node. However, instead of just editing the value of the last node I created entirely an entirely new node. This probably sounds pretty minor but in combination with everything else we were asked to do for this question it made my code far more disorganized and error-prone. When I saw this was happening I went back to reread the question and noticed that there was no reason to create a new node. I drew a big X through everything I had written and somehow managed to finish rewriting the method in the final 5 minutes of the test. For future tests, I'm going to take a bit more time to read questions carefully. In this case, skimming through a question cost me much more time than it saved.
As a side note, I really enjoyed the style of lab 8. While the other labs gave us methods and functions to write, the purpose of lab 8 was to explore and experiment with some complex code (in this case the BST delete method) and work out ways to improve it. I think the instructors did a great job altering the labs in order to accommodate the ongoing strike. Lab 8 really lead me to an in-depth understanding of the delete method when at first I had a lot of trouble it seeing how it worked.
As a side note, I really enjoyed the style of lab 8. While the other labs gave us methods and functions to write, the purpose of lab 8 was to explore and experiment with some complex code (in this case the BST delete method) and work out ways to improve it. I think the instructors did a great job altering the labs in order to accommodate the ongoing strike. Lab 8 really lead me to an in-depth understanding of the delete method when at first I had a lot of trouble it seeing how it worked.
Sunday, 15 March 2015
Week 8: Linked Lists
I found working with linked lists to be a very fun and productive challenge. While initially learning about them in lecture my first impression was that implementing linked list methods was going to be extremely straightforward. They have two parameters and a linear arrangement, how hard can it be? But once I started writing methods for lab 7 I realized that iterating over a linked list properly wasn't quite as trivial as I thought it would be. When I first began writing these methods my instinct was to use for loops. I don't remember exactly what the conditions or the bodies of these loops were but I noticed that as the methods became more demanding my code was becoming very ugly. I was able to simplify things by using break statement but in both CSC108 and CSC148 the use of break has been highly frowned upon. I felt that there should be a simpler strategies for implementing these methods. Eventually I was able to get all doctests passed but I was still dissatisfied with the aesthetic dimension of my code. I like my code to be as lean as possible. This improves its readability but I also view elegance in code as preferable for it's own sake. Given two equally effective solutions to the same problem, I would rather go with the more elegant one.
A few days later the solutions to lab 7 were released and I saw that the instructors used while loops to accomplish any iteration in linked list methods. I saw that this resulted in code significantly more simple and readable that what I had written and I was a bit disappointed in myself that I never thought to experiment with while loops. I only looked at the solution to the first couple of methods and I immediately began recoding all of lab 7 on my own with while loops. I was much more satisfied with the result this time around. I suppose this experience helped me become a bit better at problem solving. From now on I'm going to make a stronger effort to consider all tools I have at my disposal in order to come up with more simple solutions.
Thursday, 12 March 2015
Week 7: Abstract Data Types
A couple years ago, prior to studying CS, I took a statistics course which contained a particularly outspoken CS major. During one class I heard him say to an acquaintance how in CS he had encountered some extremely abstract material. This comment really caught my attention. Studying abstract topics is something I really enjoy, but at that time I had no knowledge of CS or of programming in general so I wasn't sure what he meant. Now that I have some experience with abstract data types I have a much better understanding of what he was getting at.
There are an indefinite number of ways of storing data and accessing data. Many of these are extremely useful and I find it amazing that it's possible to instantiate their structure by using a programming language. These ADTs end up being very versatile tools in a programmer's arsenal, even ones as simple as a queue.
For lab #5 (trees) we were asked to implement a method which returns a list of all values contained in the nodes of a given tree. At the time I felt that the most natural way to traverse the nodes was by using what I later found out is called a breadth-first search (http://en.wikipedia.org/wiki/Breadth-first_search). I knew that I could use recursion to easily implement the method but this would return a list with the values in a different order and for some reason I had my heart set on a breadth-first approach. Recursion didn't seem that suitable so I spent some time considering how I might solve this problem. Before too long I realized that I can add the root to a queue and while the queue isn't empty, repeat the process of dequeue-ing whatever is at the front, adding its value to the list to be returned and then enqueue-ing all of its children. This algorithm ended up producing a list of values in the order I wanted.
If I had no knowledge of the queue ADT I either wouldn't have been able to solve this problem or my solution would have been significantly more complicated. Different situations call for data to be structured in different ways. In this case, having knowledge of a first in, first out approach to organizing and accessing data is what lead me to a clean, straightforward solution to this problem.
There are an indefinite number of ways of storing data and accessing data. Many of these are extremely useful and I find it amazing that it's possible to instantiate their structure by using a programming language. These ADTs end up being very versatile tools in a programmer's arsenal, even ones as simple as a queue.
For lab #5 (trees) we were asked to implement a method which returns a list of all values contained in the nodes of a given tree. At the time I felt that the most natural way to traverse the nodes was by using what I later found out is called a breadth-first search (http://en.wikipedia.org/wiki/Breadth-first_search). I knew that I could use recursion to easily implement the method but this would return a list with the values in a different order and for some reason I had my heart set on a breadth-first approach. Recursion didn't seem that suitable so I spent some time considering how I might solve this problem. Before too long I realized that I can add the root to a queue and while the queue isn't empty, repeat the process of dequeue-ing whatever is at the front, adding its value to the list to be returned and then enqueue-ing all of its children. This algorithm ended up producing a list of values in the order I wanted.
If I had no knowledge of the queue ADT I either wouldn't have been able to solve this problem or my solution would have been significantly more complicated. Different situations call for data to be structured in different ways. In this case, having knowledge of a first in, first out approach to organizing and accessing data is what lead me to a clean, straightforward solution to this problem.
Wednesday, 25 February 2015
Week 6: Review of OOP
Last summer I was playing a lot of Hearthstone, an online card game similar to Magic: The Gathering. I wanted to know the probabilities associated with drawing certain combinations of cards before a given turn. I tried to create a program that simulated a very large number of games while keeping track of which turn particular cards were seen by. This was before I was familiar with object-oriented programming so I approached the design of this program by constructing functions that attempted to create, mutate and examine lists of tuples. I was very disappointed with how the program took shape. Even with helper functions, the code was very hard to read, the overall design felt needlessly complex and eventually I gave up on it.
About a month ago I spent some time trying to redesign this program using OOP. Although I have yet to complete this program, it's clear that an object-oriented approach has significantly improved its design. Having attributes stored in classes helped me come up with a much more precise plan for what data I was tracking and what methods I need to make it all work. Figuring out how Card, Deck and Game objects should interact feels easier (and less error-prone) than figuring out how generic lists and tuples should interact. This resulted in the new implementation being significantly leaner than the old one. Also, while the original design had methods and data arranged without any apparent organization, having methods and data stored within classes has made the code more organized and readable. I found that OOP is very conducive to having organized code. This had two important consequences. First, it was much easier fix the code when a bug was found. Second, it is now much easier to extend the functionality of the program. I already have a few ideas for new questions that this program can answer and I anticipate that these changes will be significantly more straightforward to implement relative to the old design.
Although I'm sure that my program could be made to work without OOP, this experience showed me how in many cases, using classes is just the most natural and effective way to approach program design. Classes structure your thinking and they play a major role in organizing your code.
About a month ago I spent some time trying to redesign this program using OOP. Although I have yet to complete this program, it's clear that an object-oriented approach has significantly improved its design. Having attributes stored in classes helped me come up with a much more precise plan for what data I was tracking and what methods I need to make it all work. Figuring out how Card, Deck and Game objects should interact feels easier (and less error-prone) than figuring out how generic lists and tuples should interact. This resulted in the new implementation being significantly leaner than the old one. Also, while the original design had methods and data arranged without any apparent organization, having methods and data stored within classes has made the code more organized and readable. I found that OOP is very conducive to having organized code. This had two important consequences. First, it was much easier fix the code when a bug was found. Second, it is now much easier to extend the functionality of the program. I already have a few ideas for new questions that this program can answer and I anticipate that these changes will be significantly more straightforward to implement relative to the old design.
Although I'm sure that my program could be made to work without OOP, this experience showed me how in many cases, using classes is just the most natural and effective way to approach program design. Classes structure your thinking and they play a major role in organizing your code.
Sunday, 8 February 2015
Week 5: Tracing Recursion
The feature of recursion that stands out to me most is how clean recursive code appears. There are surely some horrible-looking recursive algorithms out there, but if I were to try to implement quicksort without any recursion, I'm sure that the code would be far more complicated than what was shown in lecture.
It's helpful that this concept is being introduced so gradually (we're learning how to read recursive code before we start having to write it), but I'm ready to dive right into this material! I'm really enjoying this course but I'm also looking forward to CS courses that move at slightly faster pace.
Subscribe to:
Posts (Atom)