Skip to content
This repository was archived by the owner on Feb 10, 2021. It is now read-only.

Commit e2137a8

Browse files
committed
Add functional basics tutorial
1 parent 44e143a commit e2137a8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Diff for: functional-programming-basics/README.MD

+9-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ You're supposed to be familiar with OOP, have basic knowledge of JDK, and be abl
1010
* [Tutorial on Optional](https://github.com/bobocode-projects/java-functional-features-tutorial/tree/master/optional)
1111
##
1212
The concept of **functional programming** is based on [λ-calculus](https://en.wikipedia.org/wiki/Lambda_calculus). Which
13-
brings the idea of program that **does not use mutable variables**
13+
brings the idea of program that **does not use mutable variables**. Why is it so important? Because all race conditions,
14+
deadlock conditions, and concurrent update problem are due to mutable variables.
1415

1516
Various functional languages like [Clojure](https://clojure.org/) have been using this approach for the long time. **Java**
1617
was initially created as pure OO language, but since **version 8** it offers an ability to use either **OO and functional
@@ -63,4 +64,10 @@ public class FunctionalSumOfPrimes {
6364
}
6465
```
6566

66-
As you can see there is **no mutable variables** in the second example
67+
As you can see there is **no mutable variables** in the second example.
68+
69+
### Event Sourcing
70+
Now suppose you have enough resources (like CPU and storage), you can try to make you program functional. For instance,
71+
instead of updating bank account balance, you can **store each transaction.** When state is required, you can simple
72+
apply all transactions. This strategy, where you store transactions and not a state is called [**Event Sourcing**](https://martinfowler.com/eaaDev/EventSourcing.html). It
73+
allows you to **avoid concurrent update issues.**

0 commit comments

Comments
 (0)