An architectural boundary that isolates a domain model from the concepts and interfaces of an external system or model.
An anticorruption layer is an adapter boundary between application code and an external system. It hides third-party complexity, exposes only needed capabilities, and expresses them in the project’s domain language. section 9.2
Use the boundary to:
Mock the project-owned adapter rather than an external library interface whose behavior may be misunderstood or change during upgrades. section 9.2
Restrict upgrade ripple effects to the adapter instead of spreading third-party changes across the codebase. section 9.2
Avoid wrappers for in-process dependencies unless the added abstraction provides worthwhile value. section 9.2
Message-bus adapter
An IBus interface in a CRM application can wrap a message-bus library, exposing application-specific operations while allowing tests to mock IBus and verify messages without coupling to the library’s interface. section 9.2
How Unit Testing Principles, Practices, and Patterns covers it
How deep it goes
Defines adapters that hide library complexity, expose needed features in domain language, and limit upgrade ripple effects to one class.
Examples
Uses an IBus wrapper around a message-bus library and verifies an email-change message through the project-owned interface.
What it assumes
Assumes familiarity with external libraries and mocking, while distinguishing unmanaged dependencies from in-process dependencies.
What you can do after
Apply it by wrapping an external library, exposing needed domain operations, and mocking the wrapper in tests.
How it connects
Connects adapters with mocking, unmanaged dependencies, third-party libraries, domain language, and message buses.
Learn Go with Pocket-Sized ProjectsAn anti-corruption layer is an integration boundary that translates an external model into a domain's internal model while preventing unwanted coupling.
bubble patternused by · The bubble pattern is a migration pattern in which a new subsystem with a fresh domain model is placed in front of an existing subsystem and gradually takes over its logic.
adapterincludes · The adapter pattern is a structural design pattern in which a component translates between interfaces or representations so otherwise incompatible components can work together.
eventuses · An event is an occurrence, change, or associated record or notification recognized as significant within a system or context.
raw typehas part · A raw type is a Java generic type used without specifying its type arguments, weakening compile-time type checking for that use.
This explainer was generated by Manning's knowledge graph from the text of Unit Testing Principles, Practices, and Patterns. The section links point to the parts of the book it draws on.