Over engineering humanised-jobnames

I recently took the opportunity to heavily over engineer what should have been about 15 lines of python into a docker based microservice called humanised-jobname. I had a small application that I wanted to add Docker-esque memorable names to and over the course of a few lunch breaks I essentially built an entire repository around the equivalent to 12 lines of code from the Moby container name generator. And I enjoyed every minute of it.

Just to highlight how gold plated this is, here’s the original Docker / Moby code in its glory.

// GetRandomName generates a random name from the list of adjectives and surnames in this package
// formatted as "adjective_surname". For example 'focused_turing'. If retry is non-zero, a random
// integer between 0 and 10 will be added to the end of the name, e.g `focused_turing3`
func GetRandomName(retry int) string {
begin:
        name := fmt.Sprintf("%s_%s", left[rand.Intn(len(left))], right[rand.Intn(len(right))])
        if name == "boring_wozniak" /* Steve Wozniak is not boring */ {
                goto begin
        }

        if retry > 0 {
                name = fmt.Sprintf("%s%d", name, rand.Intn(10))
        }
        return name
}

My .dependabot.yml configuration file alone is more than twice the length of that code. Once I had the basic class written to do the mass computation of returning two words joined by a user specified string (gasp!) I couldn’t help myself and ended up using it as a test bed for a handful of things I’ve had on my investigate list for a while. I ended up wrapping it in flask, adding prometheus metrics, experimenting with some testing libraries and then running the whole thing through a couple of different python and docker linting tool chains to see which ones I liked. This tiny chunk of actual service code provided me a chance to play with:

It’s been one of my most productive side projects in a long time. The core is small enough that adding extra tooling around it is quick to iterate over and its single core purpose is focused enough that you can easily see if something’s bringing value. I’ve found myself smiling whenever I’ve bolted another thing onto the side of the project and it’s given me a place to try out things I’d never finish evaluating in the context of larger projects.