I understand that this is probably is nearly cliche in csc 148. People either hate on python or valiantly defend python. Well, I have always been on the dislike side, but I actually have a (almost) valid reason now.
While doing the final exercise, I ran into one of the downsides of python, the idea of not completely encapsulating the attributes and forcing getter and setter functions to be written. I was using a version of the BST file that was posted in the lab notes, while the version expected by the exercise auto mark was the one posted on the course homepage. The object stored at each node in one tree was named item, while in the other it was named value. So the automaker was looking for the object under a different name than it was stored. As the error wasn't part of the code I wrote, you can imagine how long it took me to find it.
Here is the place where I can argue explicit getter and setter function would have done me lots of good. Instead of having to notice a difference of a one word attribute in the code, I would have seen multiple lines of code defining a function that would have differed. I want to argue that two function definition point out the difference in the API of the object much more explicitly.
While I understand proper documentation of the BST class would have solved this error, and it would still have been possible in a more strictly encapsulated language, the face still remains that in this case, one word in the code caused me an hour of headache before, with help from a classmate on piazza, who noticed I was referring to the object by a different name in my own comments, I was able to catch my mistake and save my final exercise mark.
PS Yes this post is delayed. It started as a draft the night of the exercise and regretfully was only finished now.
No comments:
Post a Comment