Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Saffron Library - Tales from the Engineering Pit

A topic by Studio Saffron created 14 days ago Views: 164 Replies: 3
Viewing posts 1 to 3
(1 edit)

Full Disclosure: This is a post from Jibran Khan, founder of Studio Saffron, a small studio in Karachi, Pakistan. Saffron Library is our own project, and we plan to sell courses, packs, and support around it. Nothing in this post is for sale here.

So I run an indie studio based in Karachi, Pakistan. We spent about a year building a game which we published. The game was a bunch of god classes, public statics, singletons, DRY violations, YAGNI violations, SRP violations, not an interface in sight etc etc

Rather than making another game on that ball of elastic bands, I thought let’s refactor so we can take the next swing cheaper. Turns out I have a habit of making tough refactoring calls, following a belief in a better tomorrow, and almost 1.5 years later Saffron Library slowly emerged. First as a separate repo that lived within the repo of another project. Now slowly a collection of DLLs with an accompanying documentation website.

We’ve learned many lessons along the way across art, design, engineering, and marketing, and I think we’ve built something pretty decent. For this topic I’d like to stick to engineering.

Once upon a time I found myself knee deep in reviews, with code coming at me left and right. I spent time reviewing it and found it missed some basic idea, structure, or technique, and a rewrite was in order. So I thought to myself, why not slow down the process and examine the thinking first.

Therefore in my studio an engineer will first write out one or multiple documents before writing code. These documents get reviewed by a senior before anything is worked on:

  1. A set of bullet points
  2. A template of an outline
  3. A template of a proposal

This is a set of increasingly more detailed documents, and the senior engineer can ask the junior to write what’s appropriate based on their understanding. Why did we have less detailed docs? It was done to be more in line with agile. Give the team the option to need less documentation, but still have a method to require more if needed.

The big lesson we learned along the way: it pays to formally examine thinking before writing a single line of code. 

How about you folks? Do you have any lessons like ours that help lower code churn?

(+1)

The doc-first step makes sense when rewrites come from the wrong approach rather than sloppy code. One thing that pairs well with it is a short spike before the proposal: let the engineer spend an hour or two on throwaway code to find where the hard parts are, then write the outline with that knowledge. Proposals written before anyone has touched the problem tend to guess at exactly the parts that later cause the rewrite.

Another cheap one is agreeing on the interface first, the public methods and the data they pass around, and reviewing only that before the internals get written. Small PRs help too, since catching a wrong idea at 200 lines costs far less than at 2,000.

For a game codebase I'd also keep the bar lower for prototype code that might get cut, and apply the full process once a feature survives playtesting. Curious whether your juniors found the bullet point stage useful or mostly jumped straight to the proposal.

Hey Jeremy!

Thank you so much for the valuable additions:

  1. Throwaway Code Technique - Interesting point about a throwaway attempt at the implementation. Working with code really does ground an approach beyond just theory and pondering lines. 
  2. Interface - Ye I feel this. I find myself checking things like data structures, proper names and conventions payoffs before code is written. I think starting to track method access levels could be something great to do as well.
  3. Small PRs - Totally agreed about this. When I get slapped with a 300 file PR I get a little grumpy. So I try to enforce a policy derived from the single responsibility principle (SRP) of like SRP commits. I tell them how many responsibilities does this commit have? If you have a long list go back and split it up even if it means doing it again (especially if it isn't the first time they made the mistake) the learning lesson, reduced risk to codebase, and reduced load on seniors I feel makes that exercise worth it.
  4. Prototype Code - Ye this is a good point too. Playtesting is a mechanism to reveal value in an experience so makes sense to invest time based on that.
  5. Usefulness of Bullet Point - The documentation need for a task is directed by a senior. A bit more context is that we had a few programmer folks float in and out of the studio (intern/junior/mid). I'm running a small ship now so its me and a mid, so its essentially a kind of pair programming with me reviewing PR's he submits. TBH we rarely write full on proposals anymore. I think that will change if the review chain gets larger or I'm not involved much with the design phase of some work, so its a useful mechanism to keep around. I wonder if it may vary with programmer/culture re the usefulness of agile vs less agile documentation. In my experience here in Pakistan, many developers lean toward code (execution) with little design thinking (which I suspect has some roots in Pakistan being historically an outsourcing rather than innovation hub), and things get messy fast.

When you review interfaces/public methods/data before internals, what do you look for?

Another day another architecture problem.

So my engineer submitted some code the other day where passing a reset data command to our data system would reset both the session data and the player's saved data. One command doing different things with the vague notion of data. Seemed like a Single Responsibility Principle (SRP) smell.

First step is decoupling the two. Now a reset only touches what's in session memory, and the save system can be configured independently in regards to its saving behavior, so our data system doesn't force it on anyone. If you want to wipe the save, that's its own call.

Next I realized data is such a poor name for a system, it's so vague. Everything is data. "Reset data" could mean anything, which is kind of how this happened in the first place. So we looked at it and found it could be split into two systems: definitions, which holds the read-only static templates, and state, which holds the mutable copies the game actually changes. Now if you send a reset to state, it only resets the mutable session data.

Lesson: Consider your assumptions. The name was telling us something we never questioned.

Question: How do you manage data and saving in your game?