Daily Learning Notes for July 8th, 2017

Today I had a lazy morning, went rock climbing with friends, waited in line all afternoon to finally try Howlin’ Ray’s famous fried chicken sandwiches, learned a bit about Redux, stopped by a hackathon to say hi to some friends and see the chaos, and I fixed a couple more bugs in my mob coding app!

Real-time notes

7:19pm: Hard to believe the whole day already went by! But I had a good rock climbing session, and it was certainly a unique experience to wait in line all afternoon just for some fried chicken. (It was very tasty, but not my thing.) While waiting in line, I read through a couple articles introducing Flux and Redux – those Code Cartoon articles by Lin Clark, which my friend recommended to me the other day. Then I stopped by the hackathon happening at my usual coworking space, said hi to a bunch of people, took a nap on the couch for a while, and here I am.

Personal check-in: While napping, I had several waves of anxiety and my mind was overloaded with existential crisis type thoughts. I’m really not sure what I want to be working on right now. I have plenty of ideas, but any time I think about any of my ambitions, I immediately feel unprepared to rise up to the challenge. I think my brain cycled through every idea in the list and rejected every single one of them, raising every imaginable red flag. Overall I just feel pretty lost and unsure of myself, and it’s as if half of me wants nothing more than to rediscover that single-minded focus and passion that I’ve experienced in brief bursts in the past, and the other half of me wants to give up on every single one of my goals and just keep floating along, exploring ideas without committing to any real goals or responsibilities. I know it’s important to make time for exploration and to let go of goals sometimes, but that’s no way to live! I know it wouldn’t actually make me happy. Then again, I don’t know if I’m able to find that single-minded focus and passion again. I guess the short version of this story is that I’m simply experiencing a lot of self-doubt, and that’s OK. It doesn’t mean any of my ambitions are actually wrong or unachievable. I’ve just been experiencing a lot of what are apparently called “automatic negative thoughts” and I need to practice not listening to them.

7:30pm: Anyway, I figured I would spend the evening either learning more about Redux or working on my mob coding app some more. Or I could always join the hackathon late at night and tinker with some new toys and code with other friends. But I don’t think I feel like working in a big crowd. I guess I’ll first see about wrapping up my recent refactoring of the mob coding app and see how I feel after a little while.

7:40pm: A couple more weird bugs. First, I noticed that after one disconnected, the other continues forking the Gist – or at least the log messages make it look like that! I’m very confusing. And then I discovered a new error: when a player disconnected (but only under some mysterious, specific conditions), the server crashed with another undefined variable error when checking if the current player (who no longer exists I guess!) is allowed to broadcast the editorCursorChange event. The same error is happening on the client too.

8:02pm: Distracted. I also stopped by the hackathon again briefly to see if I could score some free leftovers for my friends. No luck. Not sure what I’ll be doing tonight either or how long I’ll be working on this, but I’ll take another look right now. Maybe I’ll dig into the forking bug first. Why is it not throwing an error if the current player is trying to fork their own Gist? What’s going on?

8:16pm: OK, I found it! If two players join, the first turn ends, and then Player 1 leaves before the second turn ends, then when Player 2 tries to type, an error is thrown because getCurrentPlayer() points to array index 1 but there’s now only one player in the array! Solution: update the game state whenever players disconnect! I forgot that even though the turn hasn’t changed, the turn index still needs to be updated in this case! Hmm, but how do I update the turn index appropriately? The turn index only needs to be updated if the player that disconnected was before the current player in the array. At first I thought I could just use my handy getPlayerIndexById() function here, but I forgot that in order to get the current player’s ID, I need to know the player’s index! Hmph. Maybe I’ll just do a little math then… Decrement the turn index only if the index of the disconnected player is less than the index of the current player. As long as I do that check before removing the disconnected player from the client’s game state, then it should work fine!

8:39pm: I probably spent too much time thinking about other ways to solve this, but in any case, I added a couple lines of code to both the client-side and server-side code to fix this. Note to self: maybe I should add an issue to remind myself to consider the player ID as the state variable for current player/current turn, instead of the index of that player!

8:44pm: Fixed it! Now onto the forking bug. Looks like I just forgot to update the state of the current Gist! The owner isn’t being updated properly. Let’ see… Looks like I forgot to update a line of code in the forkAndEditGist() function to match the createGist() function. This should fix it! Testing now… Yup, fixed! Woohoo! Now, can I think of any other edits? I think I’ll call it a night though, since it’s way too hot here to concentrate!

Wrapping up: Got some ice cream sandwiches, gave away the rest of them at the hackathon, went to sleep early mostly just because it was too hot to do anything else.

Gathering string