DEV Community

Cristian Sifuentes
Cristian Sifuentes

Posted on

9 - Hexagonal, Onion, Vertical Slice — Same Forces, Different Projections

Hexagonal, Onion, Vertical Slice — Same Forces, Different Projections  <br>
*Why architectural styles are perspectives, not religions*<br>

Hexagonal, Onion, Vertical Slice — Same Forces, Different Projections

Why architectural styles are perspectives, not religions


Architectures are not competing truths.

They are different projections of the same forces.

This is Part 9 of the series:

  1. Classes in C#: From First Principles to Architectural Mastery
  2. Abstract Class vs Interface — A Systems View
  3. Composition vs Inheritance — The Physics of Change
  4. Encapsulation & Information Hiding — Designing for Ignorance
  5. SOLID Revisited — A Post-Pattern Perspective
  6. Polymorphism — Substitution Over Reuse
  7. Clean Architecture as a Consequence, Not a Pattern
  8. When Not to Use OOP — The Cost of Abstraction
  9. Hexagonal, Onion, Vertical Slice — Same Forces, Different Projections

This article explains why these architectures feel different,

yet solve the same underlying problem.


The False Debate

Discussions often sound like:

  • “Hexagonal is better than Clean”
  • “Vertical Slice is more modern”
  • “Onion is simpler”

These debates miss the point.

They argue over shapes, not forces.


Architecture as Projection

Imagine architecture as physics.

The system has:

  • forces (change, volatility, coupling)
  • constraints (teams, tools, time)
  • invariants (business rules)

Architectural styles are coordinate systems

ways of viewing the same reality.

Change the viewpoint.
The forces stay the same.


The Common Enemy: Volatile Detail

All three architectures exist to solve one problem:

How do we prevent volatile details from corrupting stable policy?

UI, databases, frameworks, protocols —

these change faster than business meaning.

Every style draws boundaries to contain that volatility.


Hexagonal Architecture (Ports & Adapters)

What it emphasizes

  • Explicit boundaries
  • Input/output symmetry
  • Technology independence
   [ Adapter ] ---> [ Port ] ---> [ Core ]
Enter fullscreen mode Exit fullscreen mode

Strengths

  • Clear integration points
  • Excellent testability
  • Framework isolation

Trade-offs

  • Can feel abstract
  • Overkill for simple apps

Hexagonal is best when integration complexity dominates.


Onion Architecture

What it emphasizes

  • Domain purity
  • Dependency direction
  • Layered protection
UI -> Application -> Domain
Enter fullscreen mode Exit fullscreen mode

Strengths

  • Simple mental model
  • Strong domain focus
  • Natural fit for DDD-lite

Trade-offs

  • Layer friction
  • Temptation to add “pass-through” layers

Onion is best when domain complexity dominates.


Vertical Slice Architecture

What it emphasizes

  • Feature cohesion
  • Local reasoning
  • Change isolation
Feature A
Feature B
Feature C
Enter fullscreen mode Exit fullscreen mode

Each slice cuts vertically through all layers.

Strengths

  • Minimal ceremony
  • Fast change
  • Reduced cross-feature coupling

Trade-offs

  • Harder global consistency
  • Requires discipline to avoid duplication

Vertical Slice shines when change frequency dominates.


Same Forces, Different Emphasis

Force Hexagonal Onion Vertical Slice
Volatility control Ports Layers Feature isolation
Dependency direction Inward Inward Localized
Change localization Adapters Layers Slices
Primary driver Integration Domain Features

None of these cancel the others.

They rotate the same problem space.


Why Mature Systems Mix Styles

Real systems rarely use one style purely.

Common combinations:

  • Onion core + Hexagonal adapters
  • Vertical slices inside a Clean Architecture boundary
  • Hexagonal ports grouped per slice

This is not inconsistency.
It is context sensitivity.


The Smell of Architectural Dogma

You’re probably doing it wrong if:

  • style choice comes before problem understanding
  • diagrams matter more than dependency direction
  • refactoring feels dangerous
  • adding a feature requires touching unrelated code

Architecture should reduce fear, not create it.


Choosing a Projection (A Practical Guide)

Ask:

  1. What changes most often?
  2. What must be protected?
  3. Where does complexity accumulate?
  4. How do teams work?

Then choose the projection that makes those forces visible.


The Mental Model to Keep

Architectures are lenses.

Forces are real.

Change the lens.
Don’t deny the forces.


Final Takeaway

Junior developers ask:

“Which architecture should we use?”

Senior engineers ask:

“Which forces do we need to see clearly?”

Answer that —

and the architecture will reveal itself.


✍️ Cristian Sifuentes

.NET / C# • Architecture • Systems Thinking

Style is optional.

Forces are not.

Top comments (0)