If the logic in my domain model depends on a 3rd party component or some in house custom library/manager .dll, is it acceptable to create this dependency? I obviously have no reliance/dependency on the any facade or persistence layers to my domain layer, but I was curious if the other types of dependencies break any rules of DDD?
In general I agree with this answer, which is especially true if a 3rd party library
However I think that some 3rd party library can be referenced directly from you domain code (otherwise you would not be able to use built-in java/c# types because they can also be considered a 3rd party). These are the libraries that don't have any of the above characteristic, noda-time for example. I can also see how some math or collection libraries can be referenced directly depending on your domain.
In DDD, this type of scenario is handled with an anti-corruption layer. What this basically entails is your encapsulate the 3rd party API behind a repository or domain service. You create a local model of the 3rd party API which can then integrate with the rest of your domain layer.
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