# Good Solutions Are Beautiful

## Poincare and Beautiful Solutions

The mathematician Henri Poincare had an interesting theory of how mathematicians develop solutions and theorems. He said that solutions to complex problems are found in three steps.

First of all, the mathematician becomes familiar with the problem. She studies and analyzes all the implications and branches. She even tries to solve it consciously. Yet, if the problem is complex enough, this step never yields a solution.

In the second step, the problem seems to be abandoned. The mathematician gives up trying to solve it. Yet, it triggers a whole different process involving the subconscious. The subconscious realigns, shuffles, combines and modifies all the elements that the conscious mind collected trying to find the solution. At some point, a combination of elements is considered to be a solution and is brought up to the conscious mind.

The final step is to consciously and rigorously test and assess that the solution found by the subconscious mind is indeed a solution.

Poincare explains how based on his experience, the subconscious doesn’t know when an idea is right or wrong. The subconscious doesn’t know about mathematics, logic, or even solutions to problems. Instead, the subconscious knows about aesthetics, symmetry, and beauty. Therefore, the subconscious selects a possible solution based on its elegance and aesthetic value.

Poincare thinks that mathematicians need creativity and a sense of beauty. Not just pure intellect and logic.

## Coding and Beautiful Solutions

What is true for mathematicians is also true for other jobs considered purely intellectual, for example, coding. Many complex problems are solved by simple and elegant solutions. Just like an artist needs creativity and intuition to create her work, a software engineer also needs creativity and intuition when solving problems: either an elegant algorithm or a fitting abstraction.

We even have a saying for the opposite: “Code smells.” We say that a piece of code “smells” if the solution seems wrong, even though the code is working. But, elegant solutions are never “code smells.” Only ugly, hacky, convoluted, and overly engineered solutions are “code smells.”

## Intuition

Poincare’s subconscious mind to find solutions looks a lot like intuition. So we could summarize the theory as “a good mathematician has a good intuition.”

Yet, this intuition is not available to everybody. Why is that? Why do some people have better instincts than others? How do we know that we can trust our intuition?

Intuition is a subject that has been largely studied. Specialists have not yet agreed on how it works or what it is. Yet, there are a few accepted rules.

For example, the person needs to be an expert on the subject before trusting intuition. A person just learning mathematics can hardly rely on intuition to solve problems. Or a junior developer can’t expect to come up with solutions that are elegant and simple on the first day of work.

## Creativity

Coding is not considered a creative job, just like mathematics is not regarded as imaginative. Creativity seems to belong only in the arts. Yet, all jobs can be creative. I believe that it’s the person that makes it so, not just the role. For example, you can be a creative nurse or a creative accountant.

But remember that creativity does not come from day one.

Intuition and creativity are developed by experience.

Therefore, don’t get discouraged if your solutions are ugly when you learn to code. Don’t worry about elegance when you barely understand loops or classes. Keep working, keep learning, and one day you will be able to create simple and beautiful solutions.

If you like this post, consider sharing it with your friends on twitter or forwarding this email to them 🙈

Don't hesitate to reach out to me if you have any questions or see an error. I highly appreciate it.

And thanks to Bernat and Sebastià for reviewing this article 🙏

### Thanks for reading, don't be a stranger 👋

GIMTEC is the newsletter I wish I had earlier in my software engineering career.

Every other Wednesday, I share an article on a topic that you won't learn at work.

Join more than 3,000 subscribers below.