Thursday, 31 March 2016

Week 11 - A look back at Week 7

In Week 7 I discussed recursion, and the method by which I was originally taught how to implement recursive code. I said that when I was first learning recursion " I was taught to never try and trace the program, but instead rely on constructing robust base cases, and sound logic in making the recursive calls."


Upon working a bit more with recursion I still think this is one of the best ways to introduce recursion to students who have never worked with it. While I see the values of tracing recursive calls I think it can be misleading from one of the keys of recursion - the base cases. I don't know many of my peers in this course, but overhearing others work through some of the recursion exercises in my lab I heard people getting hung up on going step by step through what was taking place in their recursive calls, instead of focusing on whether or not the logic they used to construct their base cases was sound. Writing accurate docstring as a template for your recursive call and implementing based solely on those ideas can often bring you close (or all the way) to a perfectly implemented method. 

Another point of emphasis I've noticed in this course that has puzzled me slightly has been the focus on writing (relatively) complicated list comprehensions in order to produce more compact code. While I see the value in comprehensions, I've seen one or two examples of students trying to write an entire method in a single, complex comprehension. One line solutions to a problem can be incredibly satisfying, but in my opinion can often hinder the readability of your code. I much prefer if my partner produces 5 or 6 lines of clean code that is more readable, intuitive, and produces an equally correct solution. Maybe that's just me though.

All in all the semester is winding down. I'm looking forward to a relatively low-key exam period (only three exams) and starting the summer off on a positive note. 

Wednesday, 23 March 2016

Week 10

Finally submitted A2. There were a few incredibly frustrating bugs I had to deal with for this assignment, one of which plagued me for upwards of 5 hours.

In trying to develop extensions for Grid Peg Solitaire I was accidentally making changes to the state of the puzzle, instead of creating new Puzzle objects and returning a list of said objects. I was puzzled (no pun intended), as I wasn't actively adjusting any of the attributes of self in any of my helper methods, but without fail in each iteration of one of my loops the board state would be altered. I eventually found out that when accessing nested lists, Python only supplies a copy of the first level of depth of the list, every subsequent sub-list is aliased (not copied) which is why I was altering the board state of self. Thankfully as soon as I made the necessary adjustments to my methods everything ran exactly as expected.

The second problem (it wasn't even really a bug) I encountered was slightly less frustrating, as it took a lot less time (and tracing) to correct. My solves were taking a very long time to run, especially for some of the larger puzzles available for testing. I took the advice of some of my peers on Piazza and switched the data structure used for storing already-visited board states to a set. I also realized what a potential use for __repr__ might be (comparing string representations of the current state and all the states stored in the aforementioned set) and so implemented that for my four puzzles. After making this switch my solves took SIGNIFICANTLY less time. A satisfying adjustment.

All in all the assignment took less time than I imagined it might (thankfully, as my being sick for two weeks leading up to it only allowed me about a day to really work on it). I'm expecting a very positive result. Hopefully I'm not disappointed.

Wednesday, 16 March 2016

Week 9

Just got out of the second midterm. I feel like it went pretty well, a good thing as I was one of the students who couldn't write the first midterm due to the fire alarm incident. I don't think I made any mistakes in the midterm. I finished in about 20 minutes so I had a lot of time to look over my solutions, and am pretty confident. Unfortunately, because of the nature of the formula that my test 1 grade is being determined by, I need to hope that everyone else didn't find the midterm as straightforward as I did. The recursion tracing question contained possibly the only curveball in the entire midterm in my opinion, but once the second parameter of print was clarified it proved just as simple as a recursion tracing problem might be expected to be.

As I'm not able to attend lectures in this course due to a scheduling conflict, I was a bit concerned that the emphasis on list comprehensions in this course might leak into a term test question. I'm confident in my ability to read comprehensions, but as I don't really see the point in trading off readability for compression I don't often practice writing them. Thankfully we weren't evaluated on them, and until we receive our results I'll remain very optimistic.

Monday, 14 March 2016

Week 8 - A Bit Behind Schedule

It's been a hectic 2 weeks for me so hopefully my lateness is excused.

Last weeks labs were the only real recent connection I've had to 148 material and I found the lab #7 exercise relatively straight forward. Without working on it ahead of time at all I was able to finish the lab exercise and almost all of the additional exercises. The quiz from the lab was also relatively simple, so hopefully I locked up the full 2 marks. I'm going to start working on Assignment 2 today, and since I accidentally didn't post my Week 6 blog, I'm going to try and include a few extra blogs on my process in the second Assignment.

Thursday, 3 March 2016

Week 7 - Recursion

I've been familiar with recursion since early last year, and although it doesn't often come up in my work, it is incredibly satisfying when it does. Of all concepts one can learn early in their programming education/career, recursion opens up not only countless possibilities with respect to various recursive data structures, but also can facilitate some unimaginably elegant solutions.

Personally, when I first learned recursion it seemed almost magical. I was taught to never try and trace the program, but instead rely on constructing robust base cases, and sound logic in making the recursive calls. The end result of these two major keys (anotha one), is code that is concise, elegant, and WORKS (the latter of the three often occurring to your own pleasant surprise). The magic hasn't faded to date.

Successfully implementing some recursive code is not only very satisfying, but it also gradually cements your understanding of the concept. Mastering recursion can be a powerful milestone in becoming a more efficient and effective programmer.

Tuesday, 16 February 2016

Week 5

This past week I took a first look at Assignment 1, and implemented some of the more straight forward methods. When I first sat down to work on the assignment the docstring for the various classes and methods wasn't really registering very clearly. I had a good idea what the individual methods were supposed to do, but for some reason it felt like I was missing some vital details on how the various classes interact with each other, and what the final programs functionality should be exactly. For this reason I took some time to implement most of the simpler methods, and decided that during reading week I'd revisit the assignment with a fresh pair of eyes. I have high hopes as far as my results in this course's assignments, and so I'm planning on giving myself a lot more time to complete the coursework than I usually would in another class.

On another note, I was one of the students affected by the fire alarm being pulled during the Wednesday midterm. The whole experience was extremely frustrating, especially since I prioritized studying for the midterm over working on coursework for other courses. Not to mention that the midterm looked relatively straight forward, and in the 1 minute i spent reading through the questions I developed a lot of confidence in what my grade would look like. Hopefully the solution that the department proposes is fair for all involved.

Monday, 8 February 2016

Week 4

Due to previous experience with a lot of the material introduced in the past weeks, I've yet to really encounter a topic in class that has frustrated or challenged me. Tonight, as some preparation for our upcoming midterm, I plan on beginning Assignment 1. Although we're not very deep in the course material just yet, and the assignment is likely mostly doable with what we have learned so far, larger projects always pose a challenge. Things can get even more tricky when working alone, as I plan on doing for the majority of the coursework in 148.

I guess the past lab was a bit frustrating, but only because I stubbornly banged my head against a bug when I was importing the necessary classes. It turned out to just be an IDE issue (I think) because after about 30 min it fixed itself...

Due to scheduling conflicts I'm only enrolled in 3 courses this semester. This should give me plenty of time to not only excel in the courses that I'm enrolled in, but also (hopefully) maintain the discipline to finally pick up on some side-projects I want to get going. As for python's involvement in those: stay tuned.

Thursday, 28 January 2016

Week 3 SLOG - Initial impressions

The course content to date has been relatively straight forward. In the coming weeks I'll have to refresh myself on basic Python syntax, having been pretty far removed from the last time I used the language. The first assignment should prove a relatively useful tool in regaining my sharpness with respect to the language's syntax and style. Ideally these slogs will aid me in staying on top of and up to date with course material, especially since due to scheduling conflicts I'm unable to attend lectures. All in all I'm looking forward to the upcoming semester and hope that with the help of these slogs I can accomplish the goals i've set out for myself.