Keeping Code Intuitive

My group project at Hack Reactor was an air hockey game controlled by head movements. We call it Puckhead. I handled a lot of the client-server communication, and used Socket.io for the first time. 

I loved that Socket.io was event driven. I found it to be a lot more intuitive way to define client-server relations than GET and POST requests. At first, we had the client signalling to the server when a player was ready by sending a POST request. But it felt a lot more natural to just send a 'playerReady' event to the server, with the player's ID attached.

It's always nice to be able to think of software in a way that feels natural. When my class was working on a Blackjack game, students, including me, were coming up with a lot of crazy ways to ensure that every time a player hit, he got a random card. My solution was to generate a random number to select the suit, and another to select the rank, then use those numbers to determine the card to give the player.

Another student simply used Underscore's shuffle function to shuffle the deck in the beginning, then just popped a card off every time a player hit.  Marcus Phillips pointed this contrast in approaches out to us and it really struck me.