Project 12 -- lessons learned

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Project 12 -- lessons learned

kraftwerk1611
Hi,

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.

    if( ((squaredValue=x) | (squaredValue<x)) & (squaredValue>0) ) {}

This caused me lot of grief even though I knew it from chapter 9 but this had slipped from my mind.

- Jack OS error codes give info about the possible errors that could occur and where the check should be put in code.

http://nand2tetris-questions-and-answers-forum.32033.n3.nabble.com/Jack-OS-Error-Codes-td2507451.html

Good Luck with project 12.

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Project 12 -- lessons learned

Dasso
Thanks for your advices, I hope the chapter 12 is not as challenging as the chapter 11.
Reply | Threaded
Open this post in threaded view
|

Re: Project 12 -- lessons learned

cadet1620
Administrator
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!