If you have ever found yourself late at night debugging some impossible bug that "shouldn't have happened", only to find out that it was all about some obscure global state change, come join us and see what FP has to offer.
During this workshop, you will learn how to deal with your worst enemies: shared mutable state and code you can't trust. You will do a set of exercises that focus on dealing with these problems using Java whenever possible and Scala in more advanced cases. You will learn the two fundamental tools of functional programming: pure functions and immutable values.
This event is open for all programmers that know the basics of OOP in Java. Scala knowledge is not required. We will introduce & use only the very basic syntax constructs.
- What is a function? code
- Exercise: Imperative vs Declarative code
- Functions in Scala (
def
, return type, last expression, REPL) code - Exercise: Functions in Scala code
- Coding imperatively (live coding) code
- Pure function: imperative vs functional
- Exercise: Refactoring to a pure function code
- The Pure Function
- Exercise: Pure or impure?
- Using Scala to write pure functions (live coding) code
- Exercise: pure functions in Scala code
- Testing pure functions code
- Exercise: Testing pure functions code
- Exercise: Getting burnt by mutability code
- Mutability is dangerous (
Itinerary
live coding) - Shared mutable state
- Dealing with the moving parts (OOP
Itinerary
live coding) - Building our intuitions about immutability
- Exercise: Immutable
String
API - Purely functional approach to the shared mutable state (FP
Itinerary
live coding) - Exercise: Practicing immutable slicing and appending
- Exercise: Purely functional approach to the shared mutable state (FP
LapTimes
)