Friday, April 15, 2011

I think PA2 stands for Pain in the A__ 2

PA2 is finished at last!  Here's how it went:

The first time I sat down with it, I took care of the Dog and Cat.  Pretty simple, as explained in my last blog post.

The second session was focused on the Bird.  It went through a few different iterations before it ran without throwing a debug assertion failure.  Getting the output to look right was simple.  Even the memory addresses were showing different objects as appropriate.  But it threw a debug assertion and corrupted the heap every time.

Having reached the end of my rope on the Bird problem, I decided to go ahead and write the code for the Fish. Due to the Bird's assertion failure, I was unable to test the Fish, so I just left the code as it was until I had a chance to fix the Bird.

I took a break from the whole thing and spent an afternoon at Yosemite National Park.  I think the fresh air helped, because when I returned to my hotel room (bed 'n breakfast actually), I was hit with an inspiration.  The problem with the debug assertion failure was a simple and stupid one -- as it turned out, I was just doing a couple of things out of order.  I was clearing out the string before deserializing the object rather than after.  Therefore, the original pointer address was being replaced rather than a brand new string being created.

To top it all off, the code I wrote for the Fish worked on the first try!  Yay!

No comments:

Post a Comment