swlaschin/DomainModelingMadeFunctional

How to read CheckedAddress from a data store

Opened this issue · 0 comments

Hello @swlaschin ! I know you are not maintaining this repo but I will try this anyways, who knows right? I have an implementation question that I have not been able to find the answer to. I'm currently trying to implement some of the ideas from the book in a Kotlin project, so there may be some language barriers.

But, in the book there is a service (function) that creates a CheckedAddress type. This type is private to the service and may only be created there so as to enforce invariants. I like this pattern a lot. But, when the construction of the type is so limited, how would you approach creating a CheckedAddress type from a data store? It would be nice to not have to open a back door in the domain, but that is what I have resorted to. Some languages and frameworks may offer instantiation of such types through reflection, but I haven't seen any such feature readily available in the Kotlin/Spring JPA world. I'm curious though what your thoughts on this subject would be.

Thank you for a great book and possibly for your answer to this long shot question.

//Erik