Weekend Orders

Gah. Forgot about pictures until dusk again. I should just make a mental note to think about it around breakfast and again around lunch: those are probably good times. Let’s see… oh, it’s the weekend. A picture of retail orders?

A plastic storage tub holding a bag of bagels and three bags of English muffins. Next to it are some bags of tomatoes, pints of cherry tomatoes, and jars of salsa.

We have an e-mail list: we send out availability on Thursday morning, people write back with orders by overnight on Friday, and then we have things ready for pickup (theoretically, mostly) by 10 AM on Saturday, and they can pick up any time over the weekend.

This week most people actually came today, so there aren’t many orders left. Mom does a bunch of breads (though the bagels are special: she only does those about once a month). And we’re getting into the season where everyone’s field-grown tomatoes are coming in, so demand is down and we had some we couldn’t sell and my folks made a batch of salsa.

The perishable produce is in a glass-doored refrigerator back behind the camera to the right.

What have I been up to code-wise? Arguing with people about the utility of Twine if you’re a web-dev, hrmph. I should quit doing that. But if you don’t need the whole UI, I don’t see why it’s a big deal? I was looking through my code folder for how big these pieces are, and I have most of them:

  • State management: theoretically if you’re just writing HTML/JS you don’t need any of this, but you want to allow people to save and load so you really kinda do want to be able to serialize and deserialize your data. So shove it in an object. If you don’t do anything fancy it’s just JSON.stringify and JSON.parse, plus a pair of sub-ten-line functions to save and load to the browser’s local storage and another to let them download/upload files. If you want game history it’s another couple dozen, IIRC?
  • Events… now this one I really don’t get. At its simplest, an event is just a variable that names a function, and you call it at the appropriate times. Maybe you want a 5-line helper function to let you add onto it. Or a couple functions if you want to keep multiple handlers for the same event so you can add and remove them at will. But even that’s maybe two dozen lines of code.
  • Rendering: OK, this can get complicated, but if you already do HTML and JS, why would you do anything much? I have a great little 23-line function that uses all the vanilla DOM-manipulation functions once each so you can just say things like N('button', "Click Me!", {click: function() { … }}) etc. and it nests and all that. Or for fancier stuff I have a full template engine that’s… hrm. I don’t seem to have a copy of that on this computer, or a note of which backup disk it’d be on. But I remember it being about 120 lines of PHP, or just over 100 lines of JS.
  • Programming language/macros/whatever you want to call them: I pretty much wouldn’t do this? Just use JS. It’d be easy enough to adapt the template engine to let you write JS to be run without needing to write function() { ... } boilerplate everywhere, but beyond that… why?
  • IFID: A UUIDv4 is just a random number converted to hex digits in a particular format. There are libraries you can use, but I think the last time I did it I just wrote the code out myself because it seemed silly to pull in this whole npm package mess for what turned out to be I think 12 lines of code? Maybe 16.

There’s a bunch of work on top of that, of course. In particular cycling links and things like that are a bit annoying to get right for screenreaders. But if you’re just appending text or replacing the whole “page” you can usually get away with aria-live="polite" on your main changeable text section.

Anyway. Not trivial, but I feel like people (actual web devs, even) make this stuff out to be a major deal. And most of this is stuff I independently re-invented as a self-taught programmer between the ages of 19-23, so… I don’t know. It’s hard for me to see this as difficult instead of something that any random teenager might stumble across on their own…

Whatever. I’m not gonna argue about it with people from now on; there’s really no point. And I don’t think people should jump ship from Twine if they actually like it. But if you’re like me and find that it’s horribly painful and badly designed and it always takes you twice as long to do anything significant with Twine than it would have taken to write it from scratch, then I think it’s reasonable to roll your own. Dunno.