An analysis of A1 (See http://www.cdf.toronto.edu/~heap/148/W14/Assignments/A1/a1.pdf)
The main theme of A1 is the 4-peg variant of Tower of Hanoi. It takes me 2 all-nighters to finish (no no I didn't do it right before the deadline. I just couldn't resist to finish it in one go.) The work that was to be done can be loosely divided into three main parts.
Part 1
The part includes Step 1 to Step 4, and is the implementation of a class to represent the game itself. In this part I think the most important and also the hardest task is to understand the underlying design principle - which I would say is Separation of Concern. As in this page on separation of concern on Wikipedia, under this principle a computer program is seen to be composed of different sections, each section dealing with a separated concern, which is information that interacts with the codes. The ConsoleController class will deal with user input, while the TOAHModel and Cheese classes is responsible of modelling of the game. I myself think that OOP is highly related to this design philosophy - the implementation the Cheese class not only make it object-oriented, but also separates the rules of moving cheese (in TOAHModel) from Cheeses itself. Doing this part can be a nightmare if the principle is not fully appreciated - it will basically be a blind guess on how should codes be written to work with the give starter code.
Part 2
This part is just Step 5 and Step 6, but it is the essence of this assignment - solving the 4-peg variant of Tower of Hanoi. The solution is one of the most complicated recursion I have ever written, since it acts on mutable objects and extreme care is needed to keep everything in track. My implementation is slightly clumsy, not that it didn't give back the expected result, but a lot of computation is redundant. This and the method I learnt to resolve the redundancy will be discussed in greater detail in the next post, which will focus on recursion.
Part 3 (Bonus)
This is probably the easiest part, the only difficulty is picking a standardized key for sorting lists containing cheese objects. Not really requiring specific knowledge.
Overall I don't find the assignment particularly challenging in terms of new concept, but still I think a lot of confusion can be avoided if the instructions given are more clear - after all this assignment does not involves much freedom in design and the corresponding constraints should be easily understood. I have also looked into the second assignment, which involves many more design and lots of freedom is given. Perhaps I will give a intermittent report on my progress - it seems hard.
No comments:
Post a Comment