<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Hexagonal-Architecture on IT Comparison</title><link>https://comparison.metacog.co.kr/tags/hexagonal-architecture/</link><description>Recent content in Hexagonal-Architecture on IT Comparison</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 04 Aug 2026 05:08:09 +0900</lastBuildDate><atom:link href="https://comparison.metacog.co.kr/tags/hexagonal-architecture/index.xml" rel="self" type="application/rss+xml"/><item><title>Layered Architecture vs Hexagonal Architecture: Structuring Business Logic</title><link>https://comparison.metacog.co.kr/posts/2026-08-04-layered-architecture-vs-hexagonal-architecture-structuring-b/</link><pubDate>Tue, 04 Aug 2026 05:08:09 +0900</pubDate><guid>https://comparison.metacog.co.kr/posts/2026-08-04-layered-architecture-vs-hexagonal-architecture-structuring-b/</guid><description>&lt;h2 id="overview"&gt;Overview&lt;/h2&gt;
&lt;p&gt;Layered Architecture stacks an application into horizontal &lt;strong class="kw"&gt;layers&lt;/strong&gt;, where each layer may only call the one directly beneath it. Hexagonal Architecture instead puts business logic at the center and connects it to the outside world through &lt;strong class="kw"&gt;ports and adapters&lt;/strong&gt;, so no top-to-bottom hierarchy exists at all. The distinction matters because it determines how easily you can swap infrastructure, test in isolation, and keep framework details from leaking into core logic.&lt;/p&gt;
&lt;h2 id="comparison-diagram"&gt;Comparison Diagram&lt;/h2&gt;
&lt;div class="compare-diagram"&gt;
&lt;svg viewBox="0 0 640 360" xmlns="http://www.w3.org/2000/svg"&gt;&lt;line x1="320" y1="15" x2="320" y2="345" style="stroke:var(--border)" stroke-width="1.5" stroke-dasharray="4 4"/&gt;&lt;text x="160" y="25" text-anchor="middle" style="fill:var(--primary)" font-size="16" font-weight="bold"&gt;Layered&lt;/text&gt;&lt;text x="480" y="25" text-anchor="middle" style="fill:var(--primary)" font-size="16" font-weight="bold"&gt;Hexagonal&lt;/text&gt;&lt;rect x="40" y="45" width="240" height="42" rx="4" style="fill:var(--compare-a-soft);stroke:var(--compare-a)" stroke-width="1.5"/&gt;&lt;text x="160" y="70" text-anchor="middle" style="fill:var(--content)" font-size="13"&gt;Presentation&lt;/text&gt;&lt;rect x="40" y="105" width="240" height="42" rx="4" style="fill:var(--compare-a-soft);stroke:var(--compare-a)" stroke-width="1.5"/&gt;&lt;text x="160" y="130" text-anchor="middle" style="fill:var(--content)" font-size="13"&gt;Business Logic&lt;/text&gt;&lt;rect x="40" y="165" width="240" height="42" rx="4" style="fill:var(--compare-a-soft);stroke:var(--compare-a)" stroke-width="1.5"/&gt;&lt;text x="160" y="190" text-anchor="middle" style="fill:var(--content)" font-size="13"&gt;Persistence&lt;/text&gt;&lt;rect x="40" y="225" width="240" height="42" rx="4" style="fill:var(--compare-a-soft);stroke:var(--compare-a)" stroke-width="1.5"/&gt;&lt;text x="160" y="250" text-anchor="middle" style="fill:var(--content)" font-size="13"&gt;Database&lt;/text&gt;&lt;line x1="160" y1="87" x2="160" y2="103" style="stroke:var(--compare-a)" stroke-width="1.5"/&gt;&lt;polygon points="160,105 155,97 165,97" style="fill:var(--compare-a)"/&gt;&lt;line x1="160" y1="147" x2="160" y2="163" style="stroke:var(--compare-a)" stroke-width="1.5"/&gt;&lt;polygon points="160,165 155,157 165,157" style="fill:var(--compare-a)"/&gt;&lt;line x1="160" y1="207" x2="160" y2="223" style="stroke:var(--compare-a)" stroke-width="1.5"/&gt;&lt;polygon points="160,225 155,217 165,217" style="fill:var(--compare-a)"/&gt;&lt;text x="160" y="290" text-anchor="middle" style="fill:var(--secondary)" font-size="11"&gt;Strict top-down dependency&lt;/text&gt;&lt;polygon points="480,95 527.6,122.5 527.6,177.5 480,205 432.4,177.5 432.4,122.5" style="fill:var(--compare-b-soft);stroke:var(--compare-b)" stroke-width="1.5"/&gt;&lt;text x="480" y="145" text-anchor="middle" style="fill:var(--content)" font-size="12"&gt;Domain&lt;/text&gt;&lt;text x="480" y="160" text-anchor="middle" style="fill:var(--content)" font-size="12"&gt;Core&lt;/text&gt;&lt;rect x="440" y="30" width="80" height="30" rx="4" style="fill:var(--compare-b-soft);stroke:var(--compare-b)" stroke-width="1.5"/&gt;&lt;text x="480" y="49" text-anchor="middle" style="fill:var(--content)" font-size="10"&gt;REST Adapter&lt;/text&gt;&lt;line x1="480" y1="95" x2="480" y2="60" style="stroke:var(--compare-b)" stroke-width="1.5"/&gt;&lt;rect x="540" y="107" width="80" height="30" rx="4" style="fill:var(--compare-b-soft);stroke:var(--compare-b)" stroke-width="1.5"/&gt;&lt;text x="580" y="126" text-anchor="middle" style="fill:var(--content)" font-size="10"&gt;DB Adapter&lt;/text&gt;&lt;line x1="527.6" y1="122.5" x2="540" y2="122" style="stroke:var(--compare-b)" stroke-width="1.5"/&gt;&lt;rect x="440" y="240" width="80" height="30" rx="4" style="fill:var(--compare-b-soft);stroke:var(--compare-b)" stroke-width="1.5"/&gt;&lt;text x="480" y="259" text-anchor="middle" style="fill:var(--content)" font-size="10"&gt;CLI Adapter&lt;/text&gt;&lt;line x1="480" y1="205" x2="480" y2="240" style="stroke:var(--compare-b)" stroke-width="1.5"/&gt;&lt;rect x="340" y="107" width="80" height="30" rx="4" style="fill:var(--compare-b-soft);stroke:var(--compare-b)" stroke-width="1.5"/&gt;&lt;text x="380" y="126" text-anchor="middle" style="fill:var(--content)" font-size="10"&gt;Test Mock&lt;/text&gt;&lt;line x1="432.4" y1="122.5" x2="420" y2="122" style="stroke:var(--compare-b)" stroke-width="1.5"/&gt;&lt;text x="480" y="300" text-anchor="middle" style="fill:var(--secondary)" font-size="11"&gt;Adapters depend inward on core&lt;/text&gt;&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id="comparison-table"&gt;Comparison Table&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Aspect&lt;/th&gt;
&lt;th&gt;Layered Architecture&lt;/th&gt;
&lt;th&gt;Hexagonal Architecture&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Structural organization&lt;/td&gt;
&lt;td&gt;Horizontal layers (presentation, business, persistence); each layer only calls the one below it&lt;/td&gt;
&lt;td&gt;Concentric layout with a domain core surrounded by ports and adapters; no top/bottom hierarchy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dependency direction&lt;/td&gt;
&lt;td&gt;Strictly downward: layer N depends only on layer N-1&lt;/td&gt;
&lt;td&gt;Always inward: adapters depend on the core, the core depends on nothing external&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Entry and exit points&lt;/td&gt;
&lt;td&gt;Requests enter at the presentation layer and exit at the database layer&lt;/td&gt;
&lt;td&gt;Requests enter through any driving port and exit through any driven port&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Business logic isolation&lt;/td&gt;
&lt;td&gt;Business layer is often still coupled to persistence details that leak upward&lt;/td&gt;
&lt;td&gt;Domain core is fully isolated behind port interfaces and unaware of any adapter&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Swapping infrastructure&lt;/td&gt;
&lt;td&gt;Replacing a database or UI framework often requires touching multiple layers&lt;/td&gt;
&lt;td&gt;Swapping an adapter (e.g., DB for an in-memory store) requires no changes to the core&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Testing strategy&lt;/td&gt;
&lt;td&gt;Unit tests typically mock the layer directly beneath the one under test&lt;/td&gt;
&lt;td&gt;Core logic is tested directly through ports; adapters are tested separately&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Common pitfall&lt;/td&gt;
&lt;td&gt;&amp;ldquo;Layered lasagna&amp;rdquo;: persistence concerns bleed upward into the business layer&lt;/td&gt;
&lt;td&gt;Over-engineering ports and adapters for simple CRUD apps adds needless indirection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best fit&lt;/td&gt;
&lt;td&gt;Traditional CRUD apps with a straightforward request/response flow&lt;/td&gt;
&lt;td&gt;Domain-heavy apps needing multiple interfaces (REST, CLI, events) or high testability&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id="key-differences"&gt;Key Differences&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Layered enforces dependency in one direction (top-down) while hexagonal enforces dependency inward toward the &lt;strong class="kw"&gt;domain core&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Hexagonal defines explicit &lt;strong class="kw"&gt;ports&lt;/strong&gt; as boundaries; layered relies on looser, implicit layer contracts.&lt;/li&gt;
&lt;li&gt;Layered architecture is simpler to learn but prone to &lt;strong class="kw"&gt;leaky abstractions&lt;/strong&gt; between layers.&lt;/li&gt;
&lt;li&gt;Hexagonal architecture makes it trivial to swap &lt;strong class="kw"&gt;infrastructure&lt;/strong&gt; without touching business logic.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="when-to-use-each"&gt;When to Use Each&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Layered Architecture&lt;/strong&gt;&lt;/p&gt;</description></item></channel></rss>