Assignment 2 (both parts of it) is done now, thankfully. Which means I now have time to reflect on it - on the process, what went wrong, what could have been done better and what went very well.
One thing this assignment clearly illustrated to me was the importance of planning. Since I started programming, I've developed the bad habit of jumping right into writing code rather than thoroughly reading the problem and drawing up a plan, against the insistence of all my instructors. In high school we were forced to handwrite "pseudocode" before we were allowed access to the computer. I remember that I felt it to be an absolute waste of time. After all, I could solve the problem easily, I already had the solution visualized in my head, why bother transcribing it to a piece of paper? Any unforeseen kinks or problems could be smoothed out easily later by trial and error.
And for a while, this worked for me. In fact it worked spectacularly - until this last assignment. The major difference with this assignment was the complexity of the problem, in particular with the function regex_match to compare strings to RegexTrees. In essence this function interprets a set of rules to produce its result. So I took the same approach I always have - I read the rules, I translated them into code and then I repeated the cycle of hitting run and making changes until it worked. Eventually I produced a function that worked rather nicely. Satisfied, I moved on to the next function. Then on Thursday just prior to submitting the assignment, I went to test it against different test cases posted on Piazza. And I found that while my code worked most of the time, there were some instances, using inputs I had not anticipated, where it failed. No problem I thought, I'll just have to modify the code a bit. To my dismay, after some experimentation and frustration, I found that because of the structure of my solution there was no way to accommodate the failed cases short of rewriting the function. Because I hadn't properly planned out the function and taken care to understand the problem fully, I had failed to anticipate several edge cases. So I proceeded to design a function with an incomplete picture of the problem, and so unsurprisingly produced an incomplete solution. As a result, I had to submit a regex_match that I know will fail for several different inputs, and I'm sure there are more similar cases that I did not encounter.
(I suppose this experience also highlights the importance of thorough testing and troubleshooting. Had I been more thorough, I may have noticed the problems earlier and would have had time to make the necessary changes, even if that meant rewriting the function. Of course, this could all still have been avoided had I taken more care with the initial design and planning.)
I'm an optimist so I'll end on a more upbeat note. I'm in third year and taking six courses this semester so I'm always short on time, but I was very happy with how I managed my time for this assignment. Maybe I could have started earlier, but otherwise I was able to steadily work on the problem and finish most of it well in advance of the due date. This is a nice change from pulling an all-nighter to finish Assignment 2 in CSC108 from last spring. I noticed that besides the obvious decrease in stress, giving myself longer to work on the problem had several other advantags. I found myself discovering solutions to problems I'd been having at the most random moments - while commuting to work in the morning, while brushing my teeth, while lying in bed and waiting for sleep to come. It's almost as if my brain needs time for the problem to fully soak in - and when it does, it works on it almost subconsciously.