According to Domain-Driven Design, can I import and reuse common Value Objects like Email, SocialSecurityNumber, Currency, etc. from external sources?
It seems it would be bad because I'm relying on external code in the heart of my Domain, but for the other side, it seems I would be reinventing the wheel by rewritten the same code over and over again.
Well... generic stuff like Email, SSN can be imported and reused. Basically, the problem with imported stuff is that they might mean something else in their original bounded context. For example, Currency might not be what you need for your Domain. But things like email are generic enough not to matter.
tldr; It's ok to reuse generic concepts as long as they are generic enough that they mean the same thing in your Domain.
P.S: You can reuse them even more in validating input i.e outside the domain.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With