In mathematics, there is a concept of function composition:
h = f · g
It basically means the following:
h(x) = f(g(x))
We apply function
f(x) on a result of
This is also a popular approach in functional programming.
This syntax is not the most readable since the operations are reversed in code. Another way is to use extension methods:
The order of operations is in the correct order. Our program is an implementation of some data flow.
When dealing with the higher abstraction of elevated values,
Map should be used:
Function should be generic, to be reusable. Here’s an example:
Often, our programs look as follows:
In FP, it should look more like this:
This way, the entire workflow is available in the top-level component and it’s more clear what the code actually does.
In the first image, the architecture is very rigid and difficult to change.