Member-only story
Domain Driven Design Model Value Objects
One of the core concepts of Domain-Driven Design is that we use value-objects to pass communication up the layers in the domain layer and all the way up into the presentation layer. Let me show you how to use the sealed classes and unions of the freezed package to create them.
The Freezed Package
There are several packages out there that can create value-objects. Freezed creates value objects by using code generation to create sealed classes and unions which are as a base feature are in fact value objects:
With its dependency on build runner to generate classes, you set up a build yaml configuration file to speed up code generation:
And you will have two dependency entries: