Decompose Conditional

This is one of the refactorings from Martin Fowler’s book.

Learning Goals

Session Outline

Connect - What is clean & tidy code?

Pick the correct items from a list like this:

The idea is to get them thinking about what makes code good and readable.

Concept - Decompose Conditional

This is one of the refactorings from Martin Fowler’s book, explain what it is and why you might want to do it.

Demo - TennisGame6

TennisGame6 from Tennis Refactoring Kata is designed to have a conditional that is easy to decompose. With your refactoring tools you should be able to do it quite quickly and show a version that is much easier to read and understand.

Exercise - Tennis & DiagramPrinter

Get them first to repeat what you did with TennisGame6. If they are already quite good with their tools then they will also have time to work on DiagramPrinter - use the ‘with_tests’ branch. Ask them to work on decomposing and improving conditional logic in DiagramPrinter.doPrint() and DiagramPhysicalPrinter.doPrint().

Conclusions - explain the main idea

Explain the main idea of ‘Decompose Conditional’.