Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Lift up Conditional - the Magical Refactoring

Avatar for Clare Sudbery Clare Sudbery
September 02, 2025
2

Lift up Conditional - the Magical Refactoring

(These slides are from the O'Reilly Quality Code Bootcamp that was delivered online in April and July 2023).

The first time I saw this powerful refactoring technique demonstrated, I was confused. It seemed like some dark magic indeed. But then I tried a practical example for myself, got my head around it and fell in love.

“Lift up conditional” allows you to take messy code filled with nested conditionals and repetitious code, and detangle it into something simple and beautiful that will suddenly be easier to understand and cheaper to maintain. Join me for a hands-on example and your own moment of revelation.

Avatar for Clare Sudbery

Clare Sudbery

September 02, 2025
Tweet

Transcript

  1. Hands-on techniques to improve your code base @ClareSudbery Quality Code

    Bootcamp Day 3 Continuous improvement – refactoring legacy code
  2. POLL: Parsing if statements Which of the below if statements

    is equivalent to this one? if(colour1 == colour1 && colour2 == colour2) @ClareSudbery Day 3 Part 4
  3. POLL: Parsing if statements Which of the below if statements

    is equivalent to this one? if(!(colour1 == "green" && colour2 == "blue")) @ClareSudbery Day 3 Part 4
  4. POLL: Parsing if statements Which of the below if statements

    is equivalent to this one? if(colour1 != "green" && colour2 != "blue") @ClareSudbery Day 3 Part 4
  5. POLL: Parsing if statements Which of the below if statements

    is equivalent to this one? if(colour1 == "green" && colour1 == "blue") @ClareSudbery Day 3 Part 4
  6. POLL: Parsing if statements Which of the below if statements

    is equivalent to this one? if(!(colour1 != "green" && colour2 != "blue")) @ClareSudbery Day 3 Part 4
  7. @ClareSudbery • Code is here: https://github.com/emilybache/GildedRose-Refactoring-Kata • Requirements are in

    the readme • Visit this url to fork (top right), then clone the code: • https://github.com/emilybache/GildedRose-Refactoring-Kata.git • Choose your language Use the demonstrated method to “lift up” the conditional Day 3 Part 4 Lift up conditional
  8. @ClareSudbery • Code is here: https://github.com/emilybache/GildedRose-Refactoring-Kata • Requirements are in

    the readme • Visit this url to fork (top right), then clone the code: • https://github.com/emilybache/GildedRose-Refactoring-Kata.git • Choose your language Use the demonstrated method to “lift up” the conditional Day 3 Part 4 Lift up conditional
  9. POLL: Lift up conditional – Conclusions, part 1 How confident

    do you feel about your ability to use the "lift up conditional" technique? @ClareSudbery Day 3 Part 4
  10. POLL: Lift up conditional – Conclusions, part 2 How confident

    do you feel that this is an effective technique? @ClareSudbery Day 3 Part 4
  11. Day 3 – Links @ClareSudbery Day 3 Part 5 Useful

    links from today: github.com/claresudbery/OReilly-Bootcamp- Resources/blob/main/README.md#day-three
  12. Sudbery Software Engineering Ltd Does your team want help to

    improve their software delivery? I offer coaching and workshops Email: [email protected] Mastodon: @[email protected] LinkedIn: linkedin.com/in/clare-sudbery-she-her-35939540/ Podcast: madetech.com/podcast/