Software Design: Tidy First?

Share this post

User's avatar
Software Design: Tidy First?
Guard Clause

Guard Clause

Kent Beck's avatar
Kent Beck
Jan 28, 2022
∙ Paid
27

Share this post

User's avatar
Software Design: Tidy First?
Guard Clause
15
Share

Imagine you have some code.

...some code...

Later you discover you only want to run it sometimes.

if (condition)
    ...some code...

Even later you discover a reason not to run the code.

if (condition)
   if (not other condition)
      ...some code...

As a reader, it's easy to get lost in the nested conditions. Tidy the above to:

This post is for paid subscribers

Already a paid subscriber? Sign in
© 2025 Kent Beck
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share