Daily Learning Notes for June 30th, 2017

Today I was mostly just stuck on how to simplify my mob coding app, and anxiety slowed me down a lot, but I did push through it and make a little progress. In the evening, I thoroughly enjoyed our second math study group meetup (cutting Möbius strips in half for the first time made my day!), and then I stayed out late playing board games with friends.

Real-time notes

10:25am: Off to a late start today too, because I guess I just needed more sleep last night! It felt good to sleep in late, but now I feel a bit groggy and a bit guilty for it. Also feeling anxious this morning but not even entirely sure why… Maybe because it’s the last day of the month and the end of the first half of the year, and I feel like I haven’t done enough, and I have no idea what I want to focus on for my next set of goals. I wanted to set aside some time today for reflection and planning, but now for some reason I feel like I can’t. For right now though, I guess I’ll just dive back into my mob coding app.

I finally got unstuck yesterday! Oh yeah, and I realized that I had made another incorrect assumption. The turn change system definitely is not a finite state machine! It doesn’t have a finite number of states! If I’m going to sketch out how this system works, I should start with the client and the server as two relatively simple state machines with only a couple of states. I guess I’ll sketch those out for a little bit right now.

11:26am: I took a break to answer some emails and then chat with a couple friends who joined me for some coworking today. In fact, I just sent some links about mob coding to one friend since he had never heard of it, even though he does a lot of pair programming! I also volunteered to mentor at the upcoming Write/Speak/Code conference that my other friend is organizing. That should be fun! Anyway, now I guess I should try to focus again and scribble some notes.

12:01pm: Not sure I’m getting anywhere with this, but I did a lot of scribbling and confirmed a few things for myself:

High level overview of mob coding as a state machine:

  • Each client has two main top-level states: connected or logged in. Once logged in, the client has two inner states: active (current player) or standby. When in standby, the player could be the next player, but I don’t think that necessarily counts as a separate state.

  • The game itself (the server) has two states: on or off. The timer is part of the game, but since the timers’ on/off state matches the game’s state, it probably doesn’t need to be drawn as a separate entity.

Questions:

  • How do I visualize all the functions of the server (and the turn timer) if they’re all event-based and don’t have clear or finite states?

  • How do I know if an action is the exit function of the first state or the entry function of the second state? (For example, when a user logs in or transitions from active to standby?)

  • What are the actual state variables that control the clients and the game?

  • Do I really need separate events for turnChange, updateState, and playerListChange? Should they be consolidated, and if so, how?

Time for a quick break and then maybe some more sketching. I feel like this might be a waste of time though, because I have no clue what I’m doing! But I keep reminding myself that being stuck is an honorable state and there’s no shame in it. I made a little progress just in realizing that the client has three states.

12:27pm: Looks like I’m actually going to take a lunch break first.

1:28pm: Free lunch from the new Halal Guys downtown which apparently is doing a soft opening today! I promised I would write them a nice Yelp review in exchange for letting me in even though I couldn’t actually prove that I work nearby, haha. I guess I’ll do that. OK, done. So, where did I leave off… Argh, I’m feeling anxious all over again now. Not sure if the feeling ever went away since this morning. I have a strong impulse to leave, and I want to justify it by thinking because I got through the rest of the week OK, I deserve to take a break. But I know that won’t actually make me feel any better. Sometimes I just have to push through it. Reminding myself that this is another opportunity to practice strengthening a better response to this anxious feeling. It just means I need to double down on my efforts to fight through it and remind myself that everything is OK, that I am indeed still capable of getting things done, that I will feel better again soon enough. I’m fighting the impulse to write more about these feelings as a form of procrastination. I don’t need to, though. Time to return to where I left off. If I still feel like I need a break, I can always go for a walk in a little while. But first, it doesn’t hurt to try.

So I left off with a couple questions. How can I start to answer them? I still feel stuck. I guess I can start sketching out a new diagram for this stuff in Draw.io, because my scratch paper is getting messy.

2:04pm: This doesn’t seem to be going anywhere, so maybe I should just switch to something else for a while. I’m not sure why my anxiety is so strong right now, but I’m having trouble thinking and I feel a slight burning sensation across my back and down my arms. I’m not sure what else to try next. OK, I’ll go upstairs for a short break to stretch my legs and maybe do a few pushups or something, and then try focusing again.

2:58pm: Instead I went for a walk to the nearby supermarket with my friend, but I still feel anxious. I’m not sure what I should be doing today. I told myself I would take a break this afternoon, go somewhere else for a while, and spend some time reflecting on how this year has gone and what I want to set for my next goals. But I feel overwhelmed by all of that, so I’m tempted to just stay at the coworking space all day and try to do a little more work on the mob coding app. But I don’t feel like I can concentrate on that either. The impulse to leave is still very strong, so much so that I’m starting to think maybe I should get up and leave. I don’t think that will actually help, though. Clearly I need to make a decision. OK, I’ll do my reflection and planning day over the holiday weekend. Today just doesn’t feel like the right day for it. Phew, decision made. Now I think I’ll try my original plan and go upstairs to the break room for a bit, and then return and try to concentrate again. Maybe I’ll have some more luck then.

3:49pm: I took another walk and talked to my dad on the phone for a while, since he had called this morning but I never got to call back. Apparently that was a long walk! Then I did some pushups in the break room upstairs and that woke me up a bit. I think I might be giving up on any sort of productivity today. Right now all I want is to not feel this way anymore. After fighting anxiety the entire week, even if I’ve been doing a great job of coping with it, I guess I end up exhausted eventually and start to feel like I can’t keep fighting it anymore. Maybe I should just give myself permission to give in to it and stop fighting for a while. By letting go, I feel a lot better. Maybe better enough to do a bit of work.

I’m going to take another look at those slides on UML state machines and try to outline the sequence of steps involved in changing turns in my app. OK, so there’s an important difference in what they call “completion” events versus “change” events. Here’s a question to help understand my code better: what actually triggers the turn change? Is there a condition to check? I don’t think there is!

4:03pm: I’m not sure why I feel so agitated and antsy all of a sudden, like there’s a ton of adrenaline in my system and my thoughts are all scrambled. But since I pretty much just sat down, I don’t want to get up again yet. I feel like I should keep trying for a while first. Maybe first I’ll take a step back and make a couple sketches. More art therapy.

4:55pm: How did an hour go by?! Well, good news is my nerves finally calmed down a little bit. I figured I should focus on one tiny thing, starting at the highest level. At least I finished that! I’m pretty sure I’ve now proven to myself that this app really does only have a couple of states:

High level, simplified state chart for mob coding app

High level, simplified state chart for mob coding app

This little diagram actually contains a good amount of information:

  • The player has three actual states: connected (the starting state), active, and standby. (The latter two belong to the “Logged In” composite state.)

  • Once a player logs in, they can’t return to the “connected” state; they can only disconnect, deleting the player from the game entirely!

  • Players cycle between the “active” and “standby” states throughout the game.

  • The game itself (controlled by the server) only has two states: paused (the starting state) and running.

  • The game can always transition from “paused” to “running” and vice versa.

  • Here’s the most important thing: the only event that directly affects each player’s state (once they’re logged in) is turnChange, and the only events that affect the game state are userLogin and disconnect!

How do I model all the other events in this system? I guess they’re just functions or actions, nothing to do with state. That simplifies things so much! Most importantly, this really drives home the point I discovered earlier: I really need to refactor my other events and figure out why I was using playerListChange and updateState in the first place. Or maybe I do still need them, but I need to make it clear which ones affect state and which are just functions that can be isolated from everything else in the system. OK, time for a little break before I move on to another task.

5:32pm: I didn’t actually take a break! Instead I made a couple more edits to that state chart to show the default starting states and the final end state for the players. Now I’ll take a quick break.

5:48pm: I’m looking forward to a board game night with some friends tonight! Making plans did cheer me up a bit for sure. I wish I were still more excited for tonight’s math study group, but I guess my brain just isn’t working well enough to really focus on that, so I do plan to leave early. Anyway, for the next few minutes, I figured I would look into outlining and refactoring the sequence of actions involved in starting the game (transitioning from the “paused” state to the “running” state).

Starting the game (transition from “paused” to “running”):

  • Event trigger: userLogin

  • Condition for state transition: if number of players is 0 (in other words, if the first player has just logged in!)

  • “Paused” state exit function: (I’m pretty sure there isn’t any “cleanup” required for ending this state)

  • “Running” state entry function: start the turn timer and emit the createNewGist event

I guess there’s no difference between the transition function and the entry function in this case, since there are only two states anyway. The list above doesn’t seem very useful, but it does point out that the only actions unique to starting the game are starting the turn timer and signaling the first player to create a new Gist. Now for everything else…

Server actions for every time a user logs in:

  • Add player data to list of players

  • Send current game state to all players (so clients can update the player list view and other UI elements)

  • Send current state of the user interface only to the new player

So when the first user logs in, those three actions need to happen in addition to the other actions for transitioning into the “running” state. Otherwise, only those three actions need to happen. I need to wrap up and get ready to play host for the meetup soon, so I’ll end with my next questions.

Next questions to work on:

  • In what order do these events need to happen when the game starts?

  • Should the turnChange event be fired when beginning the first turn, or should that initialization logic be separated out?

  • How should I decouple the turn change code from the code that handles adding new player data to the list of players?

  • Back to a question that keeps popping up: what’s the overlap between the data I should send clients when new users log in or disconnect and when the turn actually changes?

  • Since sometimes the disconnect event should trigger a turnChange, how can I avoid sending duplicate data when those two events are fired? (And what happens on disconnect that doesn’t happen on turnChange?)

6:31pm: Time to call it a night I guess. I feel pretty frustrated with my lack of progress today, but at least I finally pushed through my anxiety. Maybe it will all be uphill from here for the rest of the weekend. I really hope so!

Math study group meetup

Our second math study group meetup went well! We had a good turnout and lots of fun tangents to explore:

Wrapping up: Game night was fun, though it did take more effort than usual to focus on the games since I still had some anxiety on and off the whole night, plus I was sleepy. But we learned how to play a new game called “Thurn and Taxis”, named after the German noble family from the 16th century. It took a while to figure out the rules, but it was pretty fun!

Gathering string

  • Read this again sometime: “The Advantage of Being a Little Underemployed” – “taking time in the middle of your day to do stuff that doesn’t look like work is the most important part of your work day.”

  • Today I learned (#TIL) that if you cut a Möbius strip down the middle, you end up with one long twisted piece of paper that is not a Möbius strip. And if you cut a double-twisted Möbius strip (technically not a Möbius strip anymore), you end up with two interlinked twisted paper rings! This made my day! I definitely want to experiment more with this.