You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Object internal state is used only for stateful/impure collaborators.
Stateful/impure functions are always returned as closures/lambda;
extract_utm_campaign_value_from(url)# is pureget_page_title.call(url)# is impure
Quote from "Functional and Reactive Domain Modeling" book
# Why mixing domain logic and side effects is bad
### Entanglement of domain logic and side effects.
Violates separation of concerns. Domain logic and side effects are orthogonal
to each other—entanglement violates a basic software engineering principle.
### Difficult to unit test.
If domain logic is entangled with side effects, unit testing becomes
difficult. You need to resort to mocking stuff that leads to other
complications in your source code.
### Difficult to reason about the domain logic.
You can’t reason about the domain logic that’s entangled with the side effect.
### Side effects don’t compose and hinder modularity of your code.
Your entangled code remains an island that can’t be composed with other
functions.