@algrison @yot88 Objective • Learn how to refactor “legacy” code • Practice FP concepts Theatrical players refactoring Kata Exercise • Add an HTML output with the same information
@algrison @yot88 Which kind of tests ? The code already exists and works : • Easiest way to add a regression test is to find some test data, exercise the code, and approve the result • Add approval tests / snapshot tests / Golden master
@algrison @yot88 Approval tests : Create a test https://approvaltests.com/ Statement for BigCo Hamlet: $650.00 (55 seats) As You Like It: $580.00 (35 seats) Othello: $500.00 (40 seats) Amount owed is $1,730.00 You earned 47 credits StatementPrinterTests.exampleStatem ent.approved.txt
@algrison @yot88 Step by step (OO style) 1) Extract the amount calculation • For example you can use the Strategy pattern o Tragedy & Comedy • You can also use some kind of factory to retrieve the correct impl. 2) Extract the credits calculation 3) Create a specific Printer implementation • print(Line) • print(Statement)
@algrison @yot88 Step by step (FP style) 1) Extract the amount calculation • Create dedicated functions for both types • Tragedy & Comedy • Build a map of these implementations 2) Build a statement 3) Run the pipeline • Iterate • Reduce • Format