If you’ve come to functional programming from an object oriented background, you may have found it hard to grok state in a functional system.
You’re accustomed to creating and manipulating objects, but in functional languages everything is immutable.
Often the answer to this problem is to use processes to store state.
Elixir has an
Agent which is a simple construct for storing state in processes.
Let’s see if we can roll our own
Testing interfaces in isolation leads to good software design. Coupling becomes glaringly obvious when mocks and stubs get out of hand. You may have heard this called unit testing, but not everyone agrees that implies isolation. Names are important, but let’s not get caught up in terminology. The real benefit of isolated in tests is the affect it has on design.