Mental models: inversion

Recently, I got interested in mental models. For me, those things are like design patterns for problem-solving. One of the particularly interesting mental models is “Inversion.” It is based on the notion that “many hard problems are best solved when they are addressed backward.”

What does it mean to solve backward? We are supposed to address the opposite problem first.

If we want to think about methods of safe driving during winter, we may first think about ways to have a car accident in winter. Instead of trying to come up with a revolutionary driving technique that turns an average driver into Colin McRae, we should start with making a list of things we should avoid.

So how can be sure that we will have an accident during winter? We can drive faster than usual, don’t remove snow from our headlights, we can use summer or worn tires. Now we must invert the solution, and we have something that helps us solve the original problem.

“Spend less time trying to be brilliant and more time trying to avoid obvious stupidity, because avoiding stupidity is easier than seeking brilliance.”

How can we apply this method to software engineering?

Let’s look at a typical application performance problem. We want to change our programming practices in a way that makes the application faster during runtime. But first, let’s make it slower!

How to make an application slower?
We may do more database queries or use the application to do operations which should be done by the database (basically we want to end up with the infamous n+1 queries problem from Hibernate).

We may write more information to log in the critical sections of the application. We may get rid of caching or configure it in such a way that it is almost useless.

We may load more than we need, so the garbage collector needs to allocate more memory and clean it more often.

I bet we can find a dozen ways to slow down our code. Great! Let’s find them all and then… make sure that we avoid them.

Older post

How to save a machine learning model into a file

Saving a Scikit-learn model using the joblib library in Python

Newer post

Query string validation in Fastify

How to validate query parameters using Fastify

Are you looking for an experienced AI consultant? Do you need assistance with your RAG or Agentic Workflow?
Schedule a call, send me a message on LinkedIn, or use the chat button in the right-bottom corner. Schedule a call or send me a message on LinkedIn