<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Ports-and-Adapters on Java &amp; Software Architecture Knowledge Hub</title><link>https://samirsahoo.github.io/design-patterns-hub/tags/ports-and-adapters/</link><description>Recent content in Ports-and-Adapters on Java &amp; Software Architecture Knowledge Hub</description><generator>Hugo</generator><language>en-US</language><copyright>© 2026 Samir Kumar Sahoo (https://github.com/samirsahoo). All rights reserved.</copyright><atom:link href="https://samirsahoo.github.io/design-patterns-hub/tags/ports-and-adapters/index.xml" rel="self" type="application/rss+xml"/><item><title>Layered versus Hexagonal Architecture</title><link>https://samirsahoo.github.io/design-patterns-hub/hexagonal-architecture/layered-vs-hexagonal/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/hexagonal-architecture/layered-vs-hexagonal/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Layered architecture&lt;/strong&gt; stacks the code in horizontal layers — typically presentation, business and data access. Each layer calls the layer below it, so dependencies point &lt;strong&gt;down, towards the database&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Hexagonal Architecture&lt;/strong&gt;, also called &lt;strong&gt;Ports and Adapters&lt;/strong&gt; (Alistair Cockburn, 2005), puts the business logic at the centre. The core defines &lt;strong&gt;ports&lt;/strong&gt; — interfaces in its own terms — and technology-specific &lt;strong&gt;adapters&lt;/strong&gt; plug into them from outside. All dependencies point &lt;strong&gt;inwards, towards the business logic&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;The difference is one word: &lt;em&gt;direction&lt;/em&gt;. That single change has large consequences for testing and for changing technology.&lt;/p&gt;</description></item><item><title>Hexagonal Architecture with Spring Boot</title><link>https://samirsahoo.github.io/design-patterns-hub/hexagonal-architecture/spring-boot-implementation/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/hexagonal-architecture/spring-boot-implementation/</guid><description>&lt;h2 id="what-you-will-build"&gt;What you will build&lt;a class="heading-anchor" href="#what-you-will-build" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;A small order service with two use cases — &lt;strong&gt;place an order&lt;/strong&gt; (and charge for it) and &lt;strong&gt;get an order&lt;/strong&gt; — structured as Ports and Adapters:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;The &lt;strong&gt;domain model&lt;/strong&gt; enforces business rules in plain Java.&lt;/li&gt;&#10;&lt;li&gt;The &lt;strong&gt;application service&lt;/strong&gt; orchestrates use cases and talks to the outside world only through &lt;strong&gt;ports&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Adapters&lt;/strong&gt; connect the core to HTTP (Spring MVC), a database (Spring Data JPA with H2) and a payment provider (simulated, so the example needs no credentials).&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Tests&lt;/strong&gt; cover each part at the right level. The use-case tests run without Spring and without a database.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;The full source is in &lt;code&gt;examples/spring-hexagonal-orders/&lt;/code&gt;. It targets &lt;strong&gt;Java 21&lt;/strong&gt; and &lt;strong&gt;Spring Boot 4.1.1&lt;/strong&gt;.&lt;/p&gt;</description></item></channel></rss>