Build fluency in the vocabulary of isolating core business logic behind ports with adapters plugged in from outside.
0 / 5 completed
1 / 5
At standup, a dev mentions defining an application's core business logic against abstract ports it owns, then plugging in concrete adapters, such as a specific database driver or REST controller, from the outside, so swapping infrastructure never requires touching the core logic. What is this architectural style called?
Hexagonal architecture, also called ports and adapters, is exactly this: it isolates core business logic behind ports, which are interfaces the core defines, and lets concrete adapters for specific infrastructure, like a database driver or REST controller, be plugged in from the outside without the core ever depending on them directly. A hash collision is an unrelated hash-table concept about two keys sharing a bucket. This isolate-the-core-behind-ports approach is exactly why hexagonal architecture lets infrastructure be swapped or mocked without ever touching business logic.
2 / 5
During a design review, the team adopts hexagonal architecture for a payment-processing core, specifically because swapping the production payment gateway adapter for a test adapter never requires changing the core business logic. Which capability does this provide?
Hexagonal architecture here provides infrastructure-independent core logic, since the core only depends on ports it defines, letting any adapter, such as a test payment gateway, be swapped in from outside without changing the core logic at all. A core module that imports a concrete payment gateway SDK directly ties every future gateway change to editing the core itself. This depend-only-on-ports behavior is exactly why hexagonal architecture is favored for logic that must stay stable while surrounding infrastructure changes.
3 / 5
In a code review, a dev notices a payment-processing core module imports a specific payment gateway SDK's classes directly throughout its business logic, instead of depending on a port that any gateway adapter could implement. What does this represent?
This is a missed hexagonal-architecture opportunity, since depending on a port instead of the SDK directly would let any gateway adapter be swapped in without touching the core business logic. A cache eviction policy is an unrelated concept about discarded cache entries. This direct-SDK-import pattern is exactly the kind of coupling a reviewer flags once the core logic is expected to outlive any single infrastructure choice.
4 / 5
An incident report shows switching payment providers required rewriting logic scattered across dozens of files throughout the core business logic, because the core imported the old gateway's SDK directly instead of depending on a port with a swappable adapter. What practice would prevent this?
Adopting hexagonal architecture lets a new gateway be added by writing a new adapter, without touching the core logic at all. Continuing to import the payment gateway SDK directly throughout the core business logic regardless of how many files a future provider switch touches is exactly what caused the scattered rewrite described in this incident. This ports-and-adapters approach is the standard fix once core logic is confirmed to need independence from any single infrastructure choice.
5 / 5
During a PR review, a teammate asks why the team reaches for hexagonal architecture instead of a traditional layered architecture where the core depends directly on infrastructure classes, given that the layered approach is simpler to set up. What is the reasoning?
Hexagonal architecture trades a small amount of upfront indirection, defining ports and adapters, for a core that stays fully testable and swappable regardless of infrastructure changes, while a layered architecture with direct infrastructure dependencies is quicker to start but couples core logic to specific implementations, making later swaps and isolated testing harder. This is exactly why hexagonal architecture is favored for core logic expected to outlive its surrounding infrastructure, while simpler layered coupling remains acceptable for short-lived or infrastructure-stable code.