TGViewer
TechLead Bits TechLead Bits @techleadbits · 517 subscribers
Post #54 226
Hexagonal Architecture: Implementation Tips

When I have been preparing the overview of Hexagonal Architecture I read multiple articles about the topic and some of them contain useful implementation recommendations for the pattern. So let's go trough them.

The starting implementation point is the core application logic, with port interfaces defined around it, at both driving and driven sides. New ports and adapters may appear during implementation.

Tips for ports implementation:
- Do not mention the particular technology in port naming
- Do not include word ‘Port’ in the name
- Define port as a contract (interface) with no default behavior
- Port is part of inside logic, so keep it close to application logic
- Use the "this port is for …ing something" trick to define the name. For example, "this port is for notifying about blog posts" will result BlogPostNotifier interface name
- Port should follow Single Responsibility principle
- Port should follow Interface Segregation Principle: narrow-focused ports are preferable than generic ones 

Tips for adapters implementation:
- Do not use Adapter word in the name
- If possible specify technology in the name 
- Adapter should be used for a single port only
- Use Adapter pattern for implementation
- Do not introduce dependencies between different adapters
- Follow SOLID principles
- It should be possible to change and add adapters without impact on business logic
- Technology specific errors should not leave adapter boundaries (e.g., application doesn’t know anything about particular SQL errors)
- Cover adapters by integration tests

As a result it should be possible to run the application with any combination of configured ports and adapters.

References:
- Ports and Adapters as They Should Be
- Ports and Adapters Pattern

#architecture #systemdesign #patterns
  • ❤ 1
More from @techleadbits
  1. Oct 7, 2026AI & Repository Strategy For many years, there has been an ongoing debate between monorepo…
  2. Oct 1, 2026Tracer Bullets Continuing the topic from the previous post, let's talk in more detail abou…
  3. Sep 28, 2026Why Software Factories Fail "Read the Code!" is one of the key ideas from Dex Horthy's tal…
  4. Sep 21, 2026Illustrations from The Culture Map showing how different cultures compare on the scales. #…
  5. Sep 21, 2026The Culture Map Have you ever worked in international distributed teams? Or collaborated w…
  6. Sep 10, 2026Loop Engineering from First Principles Continuing the topic of Loop Engineering, I'd like…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →