Build One To Throw Away
Building a prototype just to throw away all that code? It can be a good idea.
Building a prototype just to throw away all that code? It can be a good idea. That's the situation I found myself in, after working on a jam game and deciding to rewrite and refactor my existing codebase.
The decision to rewrite does not come easily — in all my professional career, I have avoided that due to the large upfront investment cost to it. It delays delivery, and reinvents much.
Yet for the Blasphemess project, it makes sense, because of the "Build one to throw away" principle.
You Don't Know Yet What You Don't Know
Building on to throw away is basically just prototyping, and in lean startups it's useful for finding the market fit. It's also useful for discovering what you don't yet know about how to do things.
At the start of a project, details are elusive. You have to discover the tricks that make things work. You never know where the stumbling blocks are. You don't know what's easy or difficult, in totality.
So you have to learn. By doing, preferably, with some research on the side.
In my case, I learned an immense amount about object relational mappers (ORMs), and structuring my code with FastAPI. Then, a couple of years into the project, FastAPI marched onwards and changed the way things were done.
SQLModel, a wrapper around SQLAlchemy, also offered a great opportunity to simplify some code. But only if I was willing to stomach a refactor. Svelte 5 also released, introducing the major game-changer of Runes.
Many early decisions also came back to haunt me about the codebase. Things that I could refactor if I put in the time, because they were suboptimal and made things less clear to work with. Especially the combat system!
With the combination of technology's progress and sloppy design, I decided to devise a new codebase.
The Rewrite Went On
And on. And on and on it went.
Working sporadically on weekends, I managed to get the new prototype written using SQLModel, Svelte 5, a newer FastAPI, and importantly, I integrated Keycloak SSO.
There were several major design decisions that I can point to that necessitated the rewrite:
- Users and characters are now using UUIDs instead of integer IDs
- NPCs can now be impersonated by admins, and thus are nearly functionally identical to characters, e.g. have their own message logs
- Introduced a new type of entity, aka mobs/creatures
- Rewrote the UI to be dynamic using widgets. Users can have multiple UIs that they configure using JSON to make columns, tabs, and widget lists.
- Widgets themselves are configurable, i.e. the character display widget can be filtered to just allies or enemies or all characters
- Rewrote how actions work in the UI, so instead of hard coded display types ("single_dropdown", "button", "dual_dropdown") they are dynamically generated from UI element primitives
- Introduced separation of concerns to actions so that HTTPExceptions are not embedded in game logic code
- Rewrote how maps work: now things like travel routes are given a UUID rather than a random integer ID
- Simplified login flows with Keycloak SSO, and stopped rolling my own token refresh methods
- Simplified the API calls on every game refresh down to about 4 instead of 11
- Started using svelte runes instead of svelte stores
There is the months worth of progress encapsulated into bullet points.
How Things Are Going Now
In a nutshell, things are great. I can slam out a feature every morning I work on the codebase, just about. Things are much easier and cleaner to work with, and I'm starting to grow proud of my code.
Novices and hobbyists will be able to read, and eventually, contribute without too much difficulty.
If I want to make things easy to work on, I spend a lot of time simplifying. I've built frameworks that are paying off now.
There is one sore spot: mitigating cyclic dependencies in the codebase. It's okay at the moment, but I know that I have to be careful about import loops in FastAPI + Python between the different modules.
The Future of the Balsphemess Alpha
The pre-alpha/alpha release of the Blasphemess prototype is nearing.
I need only a couple of months of effort to complete it, and I know what I have left to do. Basically, I need to rewrite the new combat system, and add in the logistics "victory points" system.
With those two things completed, I will be able to launch an invite-only alpha.
From there, the trajectory is onwards and upwards. More testing, more iteration, and eventually, the release of the first real Blasphemess cluster.
See you all there, I hope!