---
title: "Discussion on \"Hexagonal architecture with Golang (part 2)\" | Hashnode"
description: "Discussion on \"Hexagonal architecture with Golang (part 2)\". We explored the Hexagonal Architecture. Now, we are ready to take the next step and apply this powerful architecture to our project."
url: "https://hashnode.com/posts/hexagonal-architecture-with-golang-part-2/64c86daa414741728981b3fb"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Hexagonal architecture with Golang (part 2)](https://ajpham97.hashnode.dev/hexagonal-architecture-with-golang-part-2?utm_source=hashnode&utm_medium=feed)

We explored the Hexagonal Architecture. Now, we are ready to take the next step and apply this powerful architecture to our project.

Aug 1, 2023 · 17 min read · ajpham97.hashnode.dev  
Read the article

-   [#golang](https://hashnode.com/tag/golang)
-   [#architecture](https://hashnode.com/tag/architecture)
-   [#microservices](https://hashnode.com/tag/microservices)
-   [#software-development](https://hashnode.com/tag/software-development)
-   [#hexagonal-architecture](https://hashnode.com/tag/hexagonal-architecture)

## Written by

[AJ Phạm](https://hashnode.com/@ajpham)

@ajpham · Ho Chi Minh city, Viet Nam

  
[View profile](https://hashnode.com/@ajpham)

Software engineer

I graduated with honors from the University of Sciences in Ho Chi Minh City. I am working as a Senior Software Engineer at VNG. I am interested in distributed systems and big data problems. I have experience in Java, Golang, Database, and Microservice. In my free time, I often blog to share my experiences as well as read more blog posts to learn and enrich my knowledge.

## Responses 1

Markdown supported · ⌘↵ to post

[Thuan Do](https://hashnode.com/@thn)

[Aug 1, 2023](https://hashnode.com/posts/hexagonal-architecture-with-golang-part-2/64c86daa414741728981b3fb/comment/64c8f378e11157a514125c88)

Can you highlight the differences between the hexagonal architecture and the layered architecture which each layer uses interface to communicate with others?

[AJ Phạm](https://hashnode.com/@ajpham)

[Aug 1, 2023](https://hashnode.com/posts/hexagonal-architecture-with-golang-part-2/64c86daa414741728981b3fb/comment/64c8f378e11157a514125c88#reply-64c90a70e11157a514125f38)

Sure, I can provide some special difference between them:

**Purpose:**

-   Hexagonal: isolation of the core business logic from external component (framework, external technical, ...).
-   Layer: Organizes the application into horizontal layers, each with specific responsibilities.

**Dependency Direction:**

-   Hexagonal: Core application is at the center and independent of external systems. Adapters depend on the core through interfaces (ports).
-   Layer: Dependency from higher to lower layers.

**Flexibility:**

-   Hexagonal: easy swapping of adapters. Changes in external systems can be accommodated without modifying the core logic.
-   Layer: it is also flexibility but changes may involve modifying multiple layers due to tighter coupling between layers.

**Testability:**

-   Hexagonal: High testability, as the core application can be tested independently using mock or fake implementations of interfaces.
-   Layer: Supports testability, but may have less isolation between components within the same layer, making unit testing more challenging.

[Thuan Do](https://hashnode.com/@thn)

[Aug 1, 2023](https://hashnode.com/posts/hexagonal-architecture-with-golang-part-2/64c86daa414741728981b3fb/comment/64c8f378e11157a514125c88#reply-64c9370ee11157a5141265bd)

[AJ Phạm](https://hashnode.com/@ajpham) Thanks for the very detailed reply.
