Intentional Design with Maintainability in Mind
Published: 2020-09-06 16:37:36

A couple years back I posted this tweet:

{% embed https://twitter.com/thomasreggi/status/925758943665811456 %}

I think about this idea every time I'm cleaning my shower with a bucket rather then a hose nozzle, or when I'm writing unit tests for a piece of some legacy code not-optimized for testing. How can we make better decisions when it comes to maintainability?

## Case in Architecture

I think about this same principle when I see beautiful elaborate industrial or architectural design.

Here's a random picture of a house I found, these top windows near the peak of the roof are solid glass they don't open like a normal window. 

![beautiful home, with hard to clean windows](https://dev-to-uploads.s3.amazonaws.com/i/mdzrhl8ztwg3quphpnkm.jpg)

How difficult is it to clean the outside of these windows? Is there a specialized window cleaner this homeowner needs to hire? Was there a consideration for cleaning in the design of this house. Now I know this may not be the best example, people with enough money to own beautiful expensive things tend not to clean of those things. But it seems like an absence of thoughtful design.

## Case in Code

I'm trying to think of a simple example where this is apparent, but also not trite. One easy trap when writing code is global variables, they can seem an easy fix when your in a pinch. This goes against purely functional principles when it comes to creating a function with a nondeterministic outcome.

```ts
let globalState = false

function modifyGlobalState (update: boolean) {
  globalState = update;
}

function useGlobalState () {
  if (x === true) return 'a'
  return 'b'
}
```

This kind of code is hard to test because of its use of globals. The writer of this code may not be thinking about the ramifications and pain points of testing it. 

## Luxury Items are Hard to Maintain

I am very sceptical when I see something expensive and beautiful that it will be difficult to maintain, the same with code and apps in a way.

There isn't anything more luxurious than a Bugatti.

![Picture of a Bugatti, a $3 million dollar car.](https://dev-to-uploads.s3.amazonaws.com/i/0qjwi9ine1ovkdts6nx0.jpeg)

When I think of what it must cost to maintain a Bugatti I think of a chart where `cost` and `maintainability` are trade-offs. The thought of caring for a Bugatti, reminds me of a chart like this. 

![Bell Chart where "cost" is on the bottom and "maintainability" is on the left, with a bell curve rising in the middle then falling back down.](https://dev-to-uploads.s3.amazonaws.com/i/4z3cl8dys8aymrjhfa4n.png)

Cheap things are hard to maintain, because they aren't designed for maintainability. Cheap things are designed to minimize cost. Expensive things on the other hand, aren't designed for the owner to maintain, because of the premium on the product people do not prioritize maintainability, the prioritize luxury. There is a sweet spot in the middle, where a products and design can prioritize both.

## The Analogue and Digital Connection

When I clean my home I think about what type of dining room chairs would make it easier to clean under the dining room table. I factor that into the decision making process when buying something. Other people may prioritize aesthetic and style, but I'm thinking if all of the chairs will fit upside down on the table top, and how heavy they are.

It's these types of considerations when purchasing a product for your home, or adding a new dependency to your project. It's all the same. Will this thing not only serve its purpose, but will it also be easy to use and maintain over time.

## Designer / Maintainer Principle

If the person who is designing the house had to live in it, would they make better decisions about maintainability? I think so. The same goes for testing code. Are there differences in code written with testing in mind then code without? 

I think there is a certain empathy and humility involved when the author or designer of something considers maintaining that thing. If was designing a bathroom toilet for instance, I believe it would be valuable to get plumbers to test out fixing it and hear what they have to say. I also think it would be valuable to down and clean the darn thing. Certain problems with a design don't pop up until regular use, I'm looking at you Apple, when the iPhone 4 has signal issues, a bumper-case was released, but the original response was ["you're holding the phone the wrong way"](https://www.engadget.com/2010-06-24-apple-responds-over-iphone-4-reception-issues-youre-holding-th.html).

## Conclusion

Whether you're writing a new piece of code, or buying a new bathroom toilet brush consider how easy it is to use, and consider how you will maintain and clean it over time.