Software Design: Tidy First?

Guard Clause

Kent Beck's avatar
Kent Beck
Jan 28, 2022
∙ Paid
27
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 your SubstackGet the app
Substack is the home for great culture