Exit e-book
Show all chapters
04
About ZIO modules
04. 
About ZIO modules

Sign up to our Newsletter

Signing up to our newsletter allows you to read all our ebooks.

I agree to receive marketing communication from Scalac.
You can unsubscribe from these communications at any time. For more information on how to unsubscribe, view our Privacy Policy.

Mastering Modularity in ZIO with Zlayer
04

About ZIO modules

As mentioned in the ZIO documentation page: “A module is a group of functions that deals with only one concern. Keeping the scope of a module limited, improves our ability to understand code, in that we need to focus on only one topic at a time without juggling too many concepts at the same time in our head”.

The idea is that ZIO allows us to define modules and use them to create different application layers relying on each other. This means each layer depends on the layers immediately below it, although it doesn’t know anything about their implementation details. This is a really powerful concept, because it improves composability and testability (because you can easily change each module’s implementation without affecting other layers).

Now, if you are thinking about how to define these modules, ZIO provides us with a nice recipe to follow when defining a new module:

modularity in zio

Don’t worry if this all seems too abstract at the moment, because we are going to be applying this recipe for reimplementing the Tic-Tac-Toe application later. The important thing for now is to realise that two important data types are mentioned in this recipe: ZLayer and Has. So let’s discuss those now.

PREVIOUS
Chapter
03
NEXT
Chapter
05