Building a game with Spring and Electron - Part 1

Setting the scene…

I absolutely love over-engineering things. I know that’s maybe a controversial opinion, but hear me out. I don’t work day-to-day as a developer, I teach complete beginners how to code. That means a lot of “can we do X with Y?”-type questions which often cover scenarios I hadn’t ever considered. I do a lot of poking and prodding around the edges of what we teach and that’s grown into a desire to do a lot of poking and prodding at the edges of my own knowledge.

Which is why I enjoy overthinking a problem. When I try to build stuff like the app I’ll talk about here I’m not trying to streamline it and shoot for maximum efficiency. Instead I’m trying to see if I can make something work, and hopefully break a few things while I’m at it to see how they work…

That brings me to here: a short series of posts describing how I went about building an app to play Rock-Paper-Scissors against the computer. This will ultimately grow into something else, but before I go wild with the bells and whistles I need to prove the concept.

Tech choices

The front end was an easy choice for me. I’ve been interested in learning about Electron for a while so that went straight to the front of the queue. I could have stuck with a browser-based game here, but that would have been less exciting for me.

Decisions about the back end were harder. I use Spring when I’m teaching so that’s where my instincts led me at first, but I’ve also recently heard about Quarkus and I’m keen to learn more about it. The big difference in speed (Quarkus is much faster) was a big temptation, but I decided to stick with Spring. I enjoy pushing myself to learn new tech, but it’s also important to take it one step at a time. Learning two new things at once has the potential to turn into a debugging nightmare!

What makes this special?

So far, so straight-forward: it’s a JS app talking to a Java app, right? It would be, but I had a couple of extra steps planned:

And that’s the big challenge for me here. Perhaps there’s a much simpler way of doing it, but this series will describe the way I found to do it and reflect on what I might change next time.

What’s the end game here?

I said I’d over-engineer it and for such a simple game I definitely have! What I’ve learned from this will feed in to other projects though, which was always the big picture here. I’ve got ideas for other apps I want to build where the Java back end will be doing something much more complex so while I could have done everything here in JavaScript and not had to worry about a separate server, I think it’s been a worthwhile experience.

What’s next?