Week 4, Day 4: It's Thursday Already?
Man, time flew by this week. I've been really enjoying working with Rails as we step into more and more complex stuff. My partner Steven I and hit the ground running as soon as we pulled up the project. We popped out the models and migrations with all associations in about 30 minutes.
Then the requirements changed!
This is not unusual. Throughout the day, as we work, the lesson plan is being updated in real-time. Whether it's clearer requirements, or more interesting problems, or bonus assignments, there's aways a healthy chance that the project instructions page will look different when you refresh it.
In this case, we were making a music app, which was initially tracking artists, bands, singles, and recordings (one single may have many recordings). After being setting up the back-end entirely and being well satisfied with ourselves, we refreshed the instructions page. And, BAM, it was time to recycle our work. We considered, for the briefest moment, starting from scratch, but we didn't put much heart in that. The new requirements were close enough to try to hack and meld them into our existing framework.
Now we were set to be tracking artists, bands, albums, songs, and tracks. With some carefully checked migrations and some thoroughly nit-picked model associations, we did what had to be done and brought our back-end up to spec. I found the experience educational. Would not be surprised at all if the instructors intentionally did not announce that they had switched the requirements-- how else are we supposed to learn how to work with migrations to fix your database schema if we're not thrown for a loop then and again?
Over the course of the day, the project instructions grew at a rapid pace. The scope must have doubled or tripled by the end of it, with all the bonus stages. With the way my partner and I approached the project, we actually ended up crossing several of the plateaus before they were ensconced as official bonus assignments.
One of the really great things I used today for the first time were nested routes. These gave me the power to pass attributes from one page to another in a RESTful fashion with hardly any effort. These came in handy when when one of our views would be called upon to update the model of a different type of entity, say a Band page that allows you to create a new Album (and ensure that  the newly created album  is associated with the band).
Another interesting topic we handled was the mystery behind check boxes. Of all the form objects in Rails, check boxes are the least straightforward. To make Rails treat a set of checkboxes as part of a single entity, we need to pass an array on a hash in the checkbox name attribute. However, we also need to safeguard that that hash gets picked up in case all check boxes are unchecked. The mechanism for that is to set a hidden field with an empty array to act as the sentinel. Pretty hacky stuff, but it was the best Rails could come up with when reconciling the limitations of HTML.
Finishing up most of the bonus stages, I left class at a reasonable hour to play my customary Thursday basketball. Had a good round of gritty, hard-fought games. I played hard like I always do. In the last game, a 3 on 3, I took an overly ambitious shot when we were down by 6 with only 3 more points for the other team to win.
It was a no-look hook, which I make sometimes, but not often enough to justify in critical game-time situations. It felt right at the time. One of my teammates called me out for taking such a shitty shot, for not caring enough to take a good look at the basket, and, flustered, he lagged on his defense. Wham! The other team scored.
I didn't change my strategy, didn't get angry, and pushed my indignation for another time. My teammate didn't know me well enough to know that I care all the time. I kept doing what I do, grabbed every rebound, set solid picks, made outlet passes. On every play, I worked like a beast to get my teammates into good spots, to close in on help defense, to box out for every board. We scored every remaining point in that game, and I had a hand in creating each of those buckets.
That's something that I feel software should do. It should make us better, it should do the hard work so we can focus on the fun part of scoring. I hope to make software that emulates the way I play basketball. But a little less trigger-happy with those hook shots.