Daily Learning Notes for April 13, 2017

Yesterday I almost finished the version history feature for my mob coding app using the GitHub Gists API! I implemented a couple lazy workarounds that I’ll have to fix later, but that’s good enough for now. I have just one last bug to fix, and then I think I can call this feature done for now!

Goals for today: Fix the bug where any code written in the delay between forking and editing a gist gets attributed to the wrong player.

Like I wrote yesterday, “I know that in order to fix this, I need to save a snapshot of the current editor content into a temporary variable or something instead of pulling directly from editor.getValue()!””

I think this is a perfect example of the difference between “passing by reference” and “passing by value”, or whatever the other thing is called, haha. I’m so sleep-deprived today I can’t even see straight, so I might type things wrong. Anyway, I’ve come across this problem before! I tend to assume that when I put an object somewhere, I’m saving a snapshot of its value at that moment in time. But no, I’m actually saving a reference to wherever that object is in memory, so the value could change! Or something like that.

Anyway, I think simply creating a temporary variable to hold the value of the code editor should fix it. I’m going to feel very silly if that doesn’t fix it!

Testing it now…

I feel so silly right now! It didn’t work! lol. But I think I see why. It has nothing to do with passing by reference or whatever. I’m not even using an object there, I’m just calling a method on an object, but it’s returning a string! So I was wrong on multiple levels.

The problem is that I’m getting that string at the wrong time in my code. I should be saving a snapshot of the code when the turn is ending, and only then! It makes more sense to pass that data through as an input to my functions. So I’ll do that instead.

OK, let’s try this out! Now I’m going to feel really, really, really silly if this doesn’t work.

Fingers crossed…

It works! Booyeah! Finally! I think this feature is done now. I’m really sleepy, so I guess this is all I’m doing today.