background-image: url(../img/fp-tower/website-background.svg) class: center, middle, white .title[Managing Complexity] ---
.sixty-two-left[.center[ ## "Software systems get replaced not when they .hl2[wear out] but when they crumble under their own weight because they have become .hl2[too complex]" ### Plain Functional Programming by Martin Odersky ]] --- # FP Function
.sixty-two-left[.center[
]] --- # Function composition .sixty-two-left[.center[
]] --- # Function composition .sixty-two-left[.center[
]] --- # Function composition .sixty-two-left[.center[
]] ---
.sixty-two-left[.center[
]] ---
--- # Generate an invoice .fifty-two-left[
] --- # Golden Tests .sixty-two-left[ ```scala def invoiceTest( order : Order, customer: Customer, fileName: String ) = test(s"check invoice $fileName"){ val expected = readFile(fileName) val result = generateInvoice(order, customer) assert(result == expected) } invoiceTest(order1, bob, "invoice-bob-1.pdf") invoiceTest(order2, bob, "invoice-bob-2.pdf") invoiceTest(order2, eda, "invoice-eda-2.pdf") ``` ] --- # Generate an invoice .fifty-two-left[
] --- # Generate an invoice .fifty-two-left[
] ---
.forty-seven-left[ #    English .center[
]] .forty-seven-right[ #    French .center[
]] --- # Generate an invoice in different languages .seventy-two-left[
] --- # Generate an invoice in different languages .seventy-two-left[
] --- # Generate an invoice in different languages .seventy-two-left[
] --- # Generate an invoice in different languages .seventy-two-left[
] --- # Generate an invoice in different languages .fifty-two-left[
] --- # Generate an invoice in different languages .fifty-two-left[.center[
]] --- # Generate an invoice (FP version)
.fifty-two-left[
] --- # Generate an invoice (FP version)
.fifty-two-left[
] .thirty-seven-right[ ```scala case class Invoice( invoiceNumber : String, createdAt : LocalDate, customerName : String, customerAddress: Address, items : List[Item], totalNet : Double, totalAfterTax : Double, ) ``` ] --- # Generate invoices (FP version)
--- # FP vs non-FP functions
.center[
] --- class: white background-image: url(../img/fp-tower/website-background.svg)
# .white[Summary]
## .white[1.] .white[Easier to test (Dependency injection)] ## .white[2.] .white[Easier to build (Lego effect)] ## .white[3.] .white[Faster to onboard developers]