App Academy Diary, Week Two

Monday 23 September 2013— I rewrote most of the tic-tac-toe game yesterday; information-theoretically speaking, the board state is only 9 lg 3 ≈ 14.26 bits, but for better or for worse, I resisted the temptation to represent it as a two-character string. Still (still!) didn't get the AI working, though. Today was our first assessment: way too easy, I thought; we were given about an hour, and I finished in under half that. Then we had a lecture/Q&A period which I thought was too long, which covered the solutions to the assessment and default hash values. Why does anyone think lectures are a good idea? I'll confess to hanging out in the back and reading a little bit from A Farewell to Alms, which I bought on a whim on Saturday at Half-Price Books (which is a nice store, although you have to wonder whose idea it was to stock so many copies of Elliptic Partial Differential Equations and Quasiconformal Mappings in the Plane). At lunch I bought coffee and food at Starbucks and spent a little more time trying to debug the tic-tac-toe AI—still to no avail, but I'll get there eventually! (Tic-tac-toe itself is dross, but it's really important to get minimax right, because it should generalize to other games without too much trouble, and we're doing chess later this week.) Speaking of games on grids, today's project was to clone Minesweeper. I worked with Jeff Fiddler, who is the Jeff from Nevada (and not the other Jeff who tried to teach math in high schools but was frustrated with the overemphasis on standardized tests). It went really well; we used pretty Unicode symbols and even got around to implementing a cursor interface (which is way better than making the user enter coordinates)!

Wednesday 25 September 2013— Yesterday and today I wrote chess with Nathan Holland! Also, it turns out that the criminal scum who steal entire bicycles are not above stealing individual wheels, either.

Our Chess

Thursday 26 September 2013— Today's exercise was to write checkers, alone (contrast to the pair programming methodology of previous days). I ... used structs to represent the checkers and moves? I like structs?

My Checkers

Saturday 28 September 2013— Yesterday was about testing. Novice programmers test their programs by running them and seeing if they give the expected results, which might be okay when your program is small and no one actually uses it, but then what happens when you wake up one day and you're in charge of maintaining a twenty-thousand-line application that people really depend on?

Enter automated testing. By writing code to test code, developers can save time and be confident that recent changes haven't broken existing functionality! (At this point a pedant smugly inquires whether this implies the necessity of writing tests for the tests, and tests for the test-testing tests, and so on ad infinitum. This arguably doesn't deserve a reply, but is in any case easily answered by the observation that we expect tests to be much simpler than the code which is their subject; it takes less information to specify what is expected of a procedure than it does to specify the details of the procedure itself.) In test-driven development, the practice is actually to write the tests first.

I paired with A. J. Gregory; after some simple exercises, our major task of the day was to write a five-card-draw poker game in the test-driven development style. I will confess that this did not go as successfully as the projects of previous days. Perhaps the art of factorizing the idea of a program into informative tests takes more than a day to learn? Or maybe we were succumbing to tiredness at the end of a very educational week, this fatigue being only a very minor sin characteristic of being human, for which we may yet be forgiven? I can't say. (Yet.)

Sunday 29 September 2013— Dear reader, suppose you're on a quest to write the Great American Web Application—maybe the latest, greatest dog-sharing site or something; I don't know. Your app is going to need some way to persistently store data—your users' screennames, emails, hashes of their passwords (use bcrypt!), their dogs to share, &c. This data isn't really part of your application proper, so it goes in a special separate file called a database, but it is that which your application operates on and fundamentally exists for the sole purpose of curating, so your app needs some way of talking to the database and asking it questions, like "Hey, Database! User #97109 wants to be friends with User #89012; write that down, huh?" or, "My dearest friend Database, when you have a moment, could you please tell me which dogs User #98471 has available to share?" But this is mere anthropomorphism; what protocol do you actually use to get your code to talk to the database? If only there were some standard vocabulary for asking questions of the database ... some sort of—systematic questioning lexicon ...

Right, so today I successfully installed MySQL after some troubleshooting effort (it turned out that I needed to apt-get the mysql-server metapackage, and not mysql-server-core-5.5), and got acquainted with it at the command-line. Data is organized into tables of columns and rows, like maybe we have a ponies table with columns for pony_id, name and pony_type, and one of the rows is 2 | Twilight Sparkle | unicorn, and if we want to update Twilight's type we say, "UPDATE ponies SET pony_type = 'alicorn princess' WHERE pony_id = 2" and if we want to just look at the earth ponies we say, "SELECT * FROM ponies WHERE pony_type = 'earth pony'".

Leave a Reply

Your email address will not be published.