Saturday, 9 November 2013
Entry 3: Assignment 2 Wrap-Up
Unfortunately these things are always easy to postpone for 'one more day', especially when it's so hard to think of a topic(and when there's work to do). I'm going to talk today a little bit about assignment 2, specifically what went right and what went less-than-right, and what I'm going to do about it in the future.
Overall, I felt it was a more straightforward assignment than assignment one. I think this is chiefly on account of the fact that we wrote assignment 2 more or less from scratch, while in assignment one we were fitting our code into a pre-existing framework that involved passing information into a gui, etc. The hardest problems in each(moving cheeses, creating RegexTrees, matching strings and Regexes) were both best addressed using recursive strategies, but the one's in assignment two were less conceptually thorny; when one is faced with a series of self-similar subproblems(eg assembling a more complicated valid regex out of other valid regexes in a nested structure) a specific recursive solution comes to mind immediately. I found more challenging, on the other hand, the task of coding a neat way to move the cheeses around.
My problem in assignment two then, was in the elegance of my code. I got my code in working order pretty quickly, but it was an absolute mess. There was a heavy reliance on special cases and the like, and the code just felt ugly. I was able to fix this to a degree, but I couldn't banish the feeling entirely. My impressions of repugnance at my solution were reinforced by comparing the length of my solution to the what the instructors and my fellow students posted on piazza. Needless to say, mine was much longer, and while I know that long code is not necessarily bad code, I couldn't help but feel that I had missed some key insight. My two problems were as follows. In the first part of the assignment, writing the constructor for RegexTree, I couldn't figure out an efficient way to parse the string, I had to write several helper functions to accomplish this in a somewhat messy fashion. My second problem was in the match function. I had to do what I felt was an inordinate amount of fussing around with the strings as I matched them to the RegexTree, and I needed about 6(!) helper functions to do it. This all for a function that the instructors said they had managed to tackle in about a dozen lines.
Overall, I don't feel badly about assignment 2. I think I grasped the core concepts(binary trees, recursion, traversal) and I expect that I'll do pretty well on it(my code appeared to function without glitch or bug). I think my feelings about my solution are probably useful indicators that I need to spend some more time programming, so I can improve my facility with some of the tools at my disposal(namely recursion).
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment