Thinking Before We Start

Some insight on how to break down the major components of our system.

How Elixir processes work

There is very little consensus within the Elixir community on how finely we should break down components. OTP is not really a way to encapsulate data, or even objects. Elixir processes work best when they span a few modules that belong together. Making processes too granular invites integrity problems the same way that global variables do. Whenever possible, concepts that belong together should be packaged together as part of the same component.

For example, we’d rather wrap a process around a chess game as a standalone component than have each piece in its own process. That way, we can enforce the board’s integrity at the game level.

Example for demonstration

We’ll be using two software components to assist us in understanding layers. The first of the two is a simple counter. We’ll make this counter using the same concepts discussed above.

Get hands-on with 1200+ tech skills courses.