Coding 2020-01-24

By Max Woerner Chase

Okay, the battery in this is getting weird enough that I need to make the switch to publishing with the new laptop.

Anyway, last week I reread a blog post that gave advice for a design pattern to use with Python. I recognized the problem it was solving as one that I'd had with a previous project, to make an auto-roller for some RPGs I wanted to play solo. Basically, I was uncomfortable with the idea of hardcoding a reference to a particular global value, like the random module. I had similar issues when I wanted to have some functions "emit" information about what they were doing. And then I wanted to sometimes control the indentation... I ended up with a weird grab-bag of parameters that various functions took, only to forward along to the next function in the call chain.

I don't want to go into details about the post right now (it's late, again; I'll try to start writing stuff up earlier tomorrow), but reading it was sort of the point in the infomercial where it shifts to color. Using the techniques in the post, I was able to pass fewer parameters in a way that gave me more robust behavior.

Before I started on this post, I did some informal testing of an auto-roller for Ironsworn, so that's ready for the weekend, and now I can freely tinker with this; maybe try to convert the reference guide I put together for my previous solo effort to code.

Again, I'll go into more detail tomorrow, but this technique is really great when it makes sense. My biggest reservation with it is that it looks... kind of weird. Oh well, I'm done for tonight, super sleepy.

Good night.