Monday 6 April 2015

Looking back...

Right from the beginning at my second post...

Previously I did not concern myself with the special functions too much as I didn't find they did anything too important, just writing them as per convention so they would function as I deemed fit (Sure I could compare objects but I never thought I would use it for, say, testing if an object is in a correct state). However I wrote that they were something neat to learn but after going through the course and the assignments I realize how useful they can really be. I think the most often used one would be the __str__ method which could be used to not only compact our code, but would be extremely useful in producing a relevant output for the user. It could also be used as a tool to assist in debugging as I would be able to see the state of the object and not the mess of the object's id which I would be interested in.


Right after that we started on recursion I wrote that I thought it to be an extremely useful concept to know and obviously that is the case. Looking back at just Assignment 2 we had to create the minimax method while just given the algorithm of how it should be done. If I hadn't taken the time to completely understand recursion I guarantee you that I would have easily spent double the amount of time I spent writing minimax. Each time the function ran I had to know and have a clear image in my mind what it was doing in certain cases and why. As I wrote before, starting with the simplest cases and slowly moving forward and drawing/brainstorming on a piece of paper was indeed the best way to get started and to wrap my mind around the problem.

I learned to experiment with the code in order to see what worked and what didn't. While minimax was a single algorithm, there were many more, some efficient some not so much, ways to write it. I mean even in Assignment 2 we were given starter code which had the Subtract Square game implemented which was part of what we did in Assignment 1. It was a quite different implementation of what our group had done but worked similarly, we wrote it in a certain manner so it would function in a specific way, to interact with the other classes in the way we saw best. Now I'm not saying there is a single best way/solution for every problem, but each has its own benefits as well as drawbacks. All in all it also really does depend on the way you approach the problem too; many different paths to a single destination I suppose.

No comments:

Post a Comment