Separating the code from domain logic and mutable shell

Sometimes, when our code processes a business transaction, it mutates some data several times. In the world of object-oriented programming languages, this is quite a common pattern. We can then separate our code into domain logic and the mutable shell. In domain logic, we simplify the code and write the business logic in a functional way using mathematical functions. As a result, this domain logic will become easy to test. In the mutable shell, we place a mutable expression; we will do this after we finish with the business logic.

Examining the code containing side-effects

Now, let's examine the following code, which contains many side-effects that we are going to refactor, and we can find ...

Get Functional C# now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.