In defense of the “god object” pattern
Tags: programming, rust, softwareengineering, softwaredevelopment
Published: 2018-02-10 22:23:21

---
title: "In defense of the “god object” pattern"
published: true
tags: programming,rust,software-engineering,software-development
canonical_url: https://medium.com/@andrew_subarctic/in-defense-of-the-god-object-pattern-abfca3b65977
description: What makes HTML and SQL so powerful is their total submission to a “driver” object.
---

… or “In advocacy of the _total submission_ pattern”

HTML is a great and durable protocol, but something hard to generalize in the world of Turing complete programming languages. So often you have the power to just tell the computer everything that you want it to do; however this also means you have been given the _responsibility_ to tell the computer everything that it should do. This is usually not what anyone&nbsp;wants.

If I were to label HTML with a term to describe why it is such a cool technology, I would want to highlight how little it actually does. There are less than 60 tags in HTML5 and most of them are deprecated. It is amazing to think of how much one can do just by mixing a few of these primitives together.

Another one of my favorite technologies is SQL. This database query language, more-or-less elegantly, captures much of the power of the [Ï€-calculus](https://en.wikipedia.org/wiki/%CE%A0-calculus). It does so in plain enough language that many non-programmers routinely use this powerful tool to create dynamic spreadsheets or drudge through reams of data to find valuable insights.

What both of these technologies share, and what I believe makes them so powerful, is their total submission to a “driver” object. For HTML there is the browser. For SQL there is the engine. The driver object becomes infinitely complicated, but the interface grounds the driver into a zone of fertility where mere mortals can interact with these dynamic objects of providence.

What prompted me to look back on this pattern now is something I have been struggling with recently, that I think is going to become huge over time: something called, ominously, _the borrow checker_. This is a concept implemented in the Rust programming language, and originating from _linear type theory_. It has frustrated me time and again, and probably similarly to others throughout the larger community. It is a thorn in the side of the _von Neumann architecture_ and directly inhibits many of the solid patterns of code that constitute what is generally thought to be good&nbsp;code.

To describe it simply, the borrow checker is a book library that **only lends to visitors that can prove that they will return the book _before coming&nbsp;due_**.

Just try to checkout a book. It will make your head&nbsp;hurt.

Now back to the topic of the “god object”. In this case it is easy to see how the Strict Library can be a good fit for this pattern. Edge code can often be broken down into pure functions or data structures. These small pieces can be connected to create even more refined yet flat semantics. I think we will be seeing more of this within the Rust community. This whole idea is still quite young in practice, and has yet to reach scale. However, as use of this toolset begins to grow, I am betting that we will see more small libraries and more pure semantics: submission then becomes one way to defer the borrow entirely.

![](https://cdn-images-1.medium.com/max/1024/1*oZiOlBGMKipvgxVNMbS3qA.jpeg)<figcaption>look but don’tÂ touch</figcaption>


_This post was originally published on [medium.com](https://medium.com/@andrew_subarctic/in-defense-of-the-god-object-pattern-abfca3b65977)_