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 18, 2025
0

Lift up Conditional - the magical refactoring

These are the slides from the two-hour List Up Conditional workshop at PulpoCon 2025 (September 19th 2025, Vigo, Spain).

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 18, 2025
Tweet

Transcript

  1. Which of the below if statements is equivalent to this

    one? if(colour1 == colour1 && colour2 == colour2) @ClareSudbery 1. if(true) 2. if(!(colour1 == "green" || colour2 == "blue")) 3. if(colour1 == "green" || colour2 == "blue") 4. if(colour1 != "green" || colour2 != "blue") 5. if(false)
  2. Which of the below if statements is equivalent to this

    one? if(!(colour1 == "green" && colour2 == "blue")) @ClareSudbery 1. if(true) 2. if(!(colour1 == "green" || colour2 == "blue")) 3. if(colour1 == "green" || colour2 == "blue") 4. if(colour1 != "green" || colour2 != "blue") 5. if(false)
  3. Which of the below if statements is equivalent to this

    one? if(colour1 != "green" && colour2 != "blue") @ClareSudbery 1. if(true) 2. if(!(colour1 == "green" || colour2 == "blue")) 3. if(colour1 == "green" || colour2 == "blue") 4. if(colour1 != "green" || colour2 != "blue") 5. if(false)
  4. Which of the below if statements is equivalent to this

    one? if(colour1 == "green" && colour1 == "blue") @ClareSudbery 1. if(true) 2. if(!(colour1 == "green" || colour2 == "blue")) 3. if(colour1 == "green" || colour2 == "blue") 4. if(colour1 != "green" || colour2 != "blue") 5. if(false)
  5. Which of the below if statements is equivalent to this

    one? if(!(colour1 != "green" && colour2 != "blue")) @ClareSudbery 1. if(true) 2. if(!(colour1 == "green" || colour2 == "blue")) 3. if(colour1 == "green" || colour2 == "blue") 4. if(colour1 != "green" || colour2 != "blue") 5. if(false)
  6. @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 Check you can run the tests in whichever language you are in. ! You probably want to delete “foo” tests. If you use csharp.xUnit, delete the two “foo” tests in ApprovalTest.cs and GildedRoseTest.cs Lift up conditional
  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. ! If you use csharp.xUnit, delete the two “foo” tests in ApprovalTest.cs and GildedRoseTest.cs 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. ! If you use csharp.xUnit, delete the two “foo” tests in ApprovalTest.cs and GildedRoseTest.cs Lift up conditional
  9. How confident do you feel about your ability to use

    the "lift up conditional" technique? @ClareSudbery 1. Not at all 2. A little 3. Medium 4. Confident 5. Very confident
  10. How confident do you feel that this is an effective

    technique? @ClareSudbery 1. Not at all 2. A little 3. Medium 4. Confident 5. Very confident
  11. @ClareSudbery Trifork Academy, Amsterdam Mon Nov 17 + Tue Nov

    18, 2025 Two-day workshop “Building Robust Maintainable Software Using genAI”
  12. Sudbery Software Engineering Ltd Does your team want help to

    improve their software delivery? Coaching, keynotes & workshops Events and info: bit.ly/claresudbery Mastodon: mastodon.social/@ClareSudbery LinkedIn: bit.ly/lin-csudbery Podcast: bit.ly/3XvyNbU