How functional programming change my Java code

Bartek „Koziołek” Kuczyński / @koziolek

Our story of Java

We start learn Java

or other OO language

DRY & KISS

YAGNI

SOLID & Design Patters

Design Patters

because we use weak language!

We start first job

TDD

BDD

DDD

All those rules we can name

Object Oriented BSDM

First time with

Functional Programming

Functional Programming

===

we have functions

Map, filter, flatMap, reduce

Side effects

Monads

Monoids

Comonads

Category Theory

Whole those Functional Programming Kamasutra

We need to join it somehow...

What happens if you join OO BSDM & FP Kamasutra in one language?

JS

Maybe we need other way?

NO!

Solution?

Trampoline pattern

Wait for Project Amber

Still something wrong...

Do not write

purely functional solution

in non functional language

Apply idea of

functional programming

Immutability

Side effects separation

Context separation

In practise

Business analytic goes functional

Focus on verbs

Identification of common parts

Generalization of nouns

Identification of common actors

Adjectives

Implementation detail

Code is shorter

S(rp)OLID etc.

What != How

Testing

Problems?

Performance

Harder to introduce

Sometimes more code

We need to understand business

Props?

Multithreading goes easy

Refactorization goes easy

We have space for experiments

We deliver value faster

Ecology

We reduce size of spec from ~1000 pages to

~150 pages

Q&A?