I have finished coding Project 12 and following are my lessons learned from this experience.
-The classes can be implemented in any order. I started with Math class but when I got stuck I moved to other classes and came back to Math class later.
-It helps to write classes in another language like Python before writing them in Jack.
-It might help to revisit chapter 9 before chapter 12. There are two chapters between chapter 9 and chapter 12, that involve doing lot of work in a language other than Jack. Before making any progress in Project 12 I actually had to go back and do it all over again before coming back to chapter 12.
- Until you see Pong game running in VM Emulator, dont think that everything is right with your code even if your classes pass all the individual tests.
- The Screen class tests probably does not check clearScreen() method. So the code could pass screen test but Pong will fail.
- When the code hangs with "Running" message then press the stop button and look at the call stack to find out which function was called last to use it as a starting point for debugging.
- Use parantheses around all the logical operations that result in True/False. This is especially important if there are more than one logical comparison inside an if/while statment like the following one.
The order of the the do Xxx.init() calls in Sys.init() matters. For instance, your Math.init() will likely require Array.new() calls which require Memory.alloc() calls, so Memory.init() must be called before Math.init(). Remember that '*' and '/' call Math functions.
After getting all the OS files running on their own in all the XxxTest directories, you will want to test with all your OS Jack files copied into each test directory. I suggest testing/debugging them in the order of their init() calls. Then test the ones that do not have init() functions. If a test fails and it looks like your code is still running doing useful work, you may need to increase the number in the .tst files' "repeat" command; Output.init() takes a huge number of instructions!
Be careful when you make changes in Jack files in the XxxTest directories that you copy the debugged files into the common directory and into all the other XxxTest directories. Several times I tracked a bug down to something I'd already fixed!