Models
Learn how to implement data models for the impure service.
We'll cover the following...
We'll cover the following...
Initial implementation
First, we’ll implement our models, which are simple and straightforward. Let’s create a class to store a single translation.
final case class Translation(lang: String, name: String)
This method works, but we can definitely do better.
Using
Option[String]is of no use because both fields have to be set. But aStringcan always benulland contain a lot of unexpected things (literally anything).
This is where refined types come to the rescue!