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 it in the DomainLogicAndMutatingState.csproj
project:
public class Librarianship { private readonly int _maxEntriesPerFile; public Librarianship( int maxEntriesPerFile) { _maxEntriesPerFile = maxEntriesPerFile; } ...