Forensic Friday 13: Death to Singletons
Hello all! It’s been some time since the Last Forensic Friday. This one is going to be a short quick update on the state of development and the game. So what’s been happening in the past 2 weeks? A serious amount of refactoring (´。_。`)
. How much? We are talking every inch of the codebase. What was the issue that caused such a major rewrite to be needed? Well you’re about to find out below!
The problem #
The problem can be described with one word. Singletons, and a hecking lot of ‘em. Turns out singletons are great for small projects, but relying on them for large projects becomes, well… very messy. A more appropriate word is spaghetti. The entire codebase was practically a messy bowl of overcooked spaghetti **that was sticky and not a pleasure to eat. If you are not familiar with the concept of a singleton, it’s basically an object that another other object can reference, and there can only be one instance of that object. Hence the name Single-ton. The latter property of singletons is great! The former seems great at first, it’s an easy way to get data around where you need it. But imagine this: A game with an increasing amount of managers, which have to handle many hundred objects, each being able to be accessed anywhere from the code. You can kind of get a picture of how messy things can get. It also leads to weird shortcuts that ruin the whole premise of OOP, but that’s a whole other problem. So what is the solution, you may be asking? Easy. **Events!
Solution: Event Driven Architecture #
Event driven architecture. A god-sent solution I wish we had seen earlier. What are events? In simple objects can tell a handful of objects something without ever directly referencing them. Great! Best thing is that it works both ways. This allows us to get rid of pesky direct calls, and replace them with a Request and Announce model. Now all the code can be decoupled, what does this mean? Well now if we make a manager for example, the game doesn’t care whether it exists or not, since we can specify default behaviour if the request isn’t satisfied; and an announcement is simply just not made if the object doesn’t exist to call it. In short, the makes the code stupidly easy to change and modify and ultimately develop. Yay! (Code stuff is pretty boring, ew. Lets move on!)
Consequences??? #
The consequences, as far as we know are all good. The biggest two are, quicker smooth development, and probably the biggest of all, modding. Event driven design makes it almost trivial to mod a game as you can hook into events naturally (whatever that means lol), and yeah good stuff really. Overall, as the refactor has been going, a lot of BAD CODE has been revealing itself, which is only a good sign. It’s almost crazy how much singletons had messed up our code. Honestly, when you only have a hammer everything truly looks like a nail! Well that’s that. The refactor is almost done, I would say it will be finished over the weekend, or at max by the end of next week (Dillan is having a bit of trouble with cleaning up the power logic but its just a small hiccup). So I would say things are looking good! Ah, there is one last thing I’d like to discuss before closing the case! We were playing with the idea of a cinematic universe of sorts. I stress the “playing”, it’s a very infant idea.
Are you serious? lol #
Yes! At least as serious as we can be! You might be interested on what exactly I mean. Well it was my proposition after all so I guess I’m most qualified to speak about. A cinematic universe! Well not a live action one. (Maybe much to your disappointment but we don’t have that much funding). The basic premise is a series of short 10 to 20 minute Animatics with possible voice acting and sound effects. (Not animations, animatics. Basically a storyboard with various degrees of animation sprinkled in. You can search it up if your curious). These animatics would be apart of an **anthology series **containing various episodes that explore different aspects of the universe. **8 episodes **to be exact.
Why do this? I could be crazy, but I think it would be an interesting way to market the game. At worst it’s a fun creative project we can be proud of and something we can use to explore the Containcorp universe and really give it a unique identity, which will always benefit the game.** At best** we generate interest for the game on a large scale, and also interest in the universe, whilst getting money to fund more episodes. I guess in both cases it would benefit the game in one way or another. And in the end, if the game does well, the anthology series would do well, and vice versa (It’s not really that simple, but roughly speaking, yes). So I guess since we want the game to do well anyways, why not do it? At least 1 episode! If your interested in what a potential episode list could look like, I’ll post it below. Though I must stress it’s really early stages and we aren’t totally sure whether we will go through with this, or can pull it off. Though it would be cool wouldn’t it?
**Show me the episode ideas!!!! ** No.
Nah, just joking. These were just some ideas I produced rather quickly, not at all final, more speculative:
- Episode 1: Would explore the transition of a new Category C into facility life, and what happens when everything goes wrong.
- Episode 2: Would explore S-0040, the Concrete Jungle, and what happens when the Corporation’s interests outweigh their researcher’s own lives.
- Episode 3: Would explore the horror genre. A task force is sent into an unknown rural town. What they encounter is beyond understanding.
- Episode 4: Would explore a Field agent, tasked with covering up an incident in a suburban town. A murder of anomalous means. The issue is, that it was his wife who was murdered.
- Episode 5: Would explore a human anomaly who is captured by the Corporation, and taken away from his family. What makes a human, human? Is it moral for the Corporation to keep a human anomaly imprisoned? What happens when they decide they don’t want to be imprisoned any longer?
- Episode 6: Memes spread fast, and quickly, reaching millions on the internet in seconds. What does the Corporation do when one of those memes is an anomalous hazard?
- Episode 7: What happens to earth when the Corporation is exposed and has to go public? What happens is that a bunch of human anomalies goes from prisoners to a celebrities; superhero status. But are their intentions aligned with humanities?
- Episode 8: Explores S-0033 the Concrete brick. Trouble stirs in a remote mining facility deep in a frozen tundra. An elite team is sent to secure it. How was it captured? A thriller short.
Let us know what you think. (I must stress, none of this is guaranteed to happen right now!)
Case closed #
Yes, that’s it! Depending on your expectations that was either super underwhelming, or very awesome (No in-betweens because we only think in 0s and 1s here). After the refactor is fully finished, and we have written tests (very fun), then development shall continue as normal. Very likely at a significantly accelerated pace. Though development is technically continuing as normal already but that is besides the point. Regardless, I hope you’re happy with the progress, albeit rather internalised, that we have made. Ah, making games is hard. I’m honestly surprised we haven’t given up (We have come close but we’ll never go through with it and leave you guys hanging. I’m probably going to keep working on this game even if it takes me to my deathbed). Well, on that rather morbid note, the case is closed! Those who read this, thank you, and I hope you all have a great summer full of relaxation, or perhaps driven goals. Whatever you guys get up to I hope it goes well! You know what we’ll be up to (it’s coding). Well, till next time!
The Team,
Plasmarc Studios