Write the Tests First

30 Sep 2020

This morning, before i woke up, there was a loud siren that began repeating over and over. Naturally, I approached my computer to write the code to make it stop. It was an easy algorithm, so I wasn’t concerned. I got it done, compiled it, and ran it.

It didn’t work! Why didn’t it work? This wasn’t good. In fact, this was very bad. By this point, i knew all too well that time was quickly running out–i needed to get this working, right now! I studied and refactored and found the mistake (it was a dumb one!). With a single keystroke, I fixed it, recompiled, and reran the program.

Obviously, it still didn’t work! I looked at a clock–there next to no time left, but as the siren sang on, I wrote the code over and over and over. Nothing was adding up. With a racing heart, I fought through the pulls of anxious defeat to begin yet another attempt to make the code right, and as I was nearing the end, something began to crush me–some alien creature was on top me! I felt its tiny finger pry its way into my mouth…

Despite my heartrate and the stress I was under, I calmly cracked open my eyes, saw Leo give me a big smile, and told Keith to shut off his alarm clock, which had been going off for hours in dreamland.

It was only a matter of time, and honestly, i think i was dreaming about code all night. It started as soon as I hit the pillow–i guess that’s what i get for reading clojure before bed.

Anyway, today was not too bad. I got all my levels working, and they actually work pretty well if I do say so myself. When I play the computer on easy, i get to win maybe 30-40% of the time. On medium, it’s less, and on hard, it’s not at all. I also figured out how to save a file with the current game and pull it back in to restart where i left off. That was very cool and actually didn’t take nearly as long as i thought it would.

I also added a bunch of tests to my gui today–the ones i’d missed. I spent too much time on that and it wasn’t fun doing that–from now on, write the tests first!