Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having 3rd Party or Custom 'Library' references in Domain Model?

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?

like image 786
atconway Avatar asked Dec 20 '12 22:12

atconway


2 Answers

In general I agree with this answer, which is especially true if a 3rd party library

  • changes often
  • does any sort of out-of-process communication
  • has a lot of dependencies of its own

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.

like image 196
Dmitry Avatar answered Oct 11 '22 16:10

Dmitry


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.

like image 37
eulerfx Avatar answered Oct 11 '22 16:10

eulerfx