How to apply the one code design rule

Mattijs
2 min readSep 19, 2019

--

Make it simpler.

How do we know we made code simpler?

When the code is easier to understand.

Can’t we add more specific rules?

More specific ideas can help but also hurt. So they can’t be rules.

Can we over-simplify?

No. If we made the code harder to understand, it is not simpler. If we removed required features, we didn’t simplify but we broke the code.

Should we always simplify more?

No. We also need to spend time on building features.

When is our code as simple as possible?

Never. So we shouldn’t try to make code as simple as possible, only as simple as necessary.

How do we know when to simplify?

  • Probably when we have too many bugs
  • Probably before we add new features
  • Probably before we add new developers

How do we know where to simplify?

  • If we go back to old code, and we see that something takes time to understand.
  • We observe someone new to the code. Every question she has is an opportunity to simplify.
  • After simplifying for 10 years, we develop a gut feeling.

How do we get better at simplifying?

  • We’re not afraid to commit less code
  • We don’t need to look smart
  • We don’t benefit from being the only one that understands our code
  • We practice a lot

What is wrong with design patterns?

Nothing, as long as we call don’t call them patterns, but examples.

What is wrong with Keep It Simple, Stupid (KISS)?

It suggests that we automatically get simple code as long as we resist the urge to overcomplicate.

Is simplifying code easy?

No. It’s the hardest thing in computer programming.

If you can’t explain it to a six-year old, you don’t understand it yourself.

Albert Einstein

Simple is Beautiful.

--

--