
Software systems rarely exist in isolation; they often interact with databases for data persistence or web services from external companies or internal teams. A significant challenge in software design is preventing our code from being contaminated by these outside details.
You may wonder why this is a problem. There are a few reasons to protect your domain from external influences. First, they can impede your ability to replace a component with something simpler, which would facilitate testing. For instance, if you lack a layer between the code that accesses an external web service and your domain logic, it becomes difficult to test the domain logic in isolation.