View it on repl.it
A related slide presentation can be found here.
The presentation covers various functional patterns that can be brought into the OOP paradigm with the goal of achieving code that is easier to understand, test, and maintain. Topics covered:
- Nulls
- Exceptions
- The Law of Demeter
- Indirect Input/Output
The code sample is a step-by-step take on Scott Wlaschin's Railway Oriented Programming example. The code has been rewritten several times in the following stages:
- Imperative
- Declarative
- Using the Result data type
- Using the Result as a monad
- Using only Pure functions
- Replacing interfaces with functions
- A version in F# for kicks
Icons made by Freepik from www.flaticon.com