Hexagonal Budapest 2023 Version
Hexagonal Budapest 2023 Version
Alistair Cockburn
Outline
Benefits
Costs
1. You must add an instance var to hold each driven actor, or get it every
time.
2. You must add a constructor parameter or a setter function for each
driven actor, or a call to the configurator to get it.
3. You must design and add a configurator.
4. (Type-checked languages) You must declare the “required” interfaces.
5. (Type-checked languages) You must add folder structure for the port
declarations.
Network tracing
GUI
system
ow! L
ow! L
Invoicing system
Invoicing SQL
GUI
system database
ow! L
ow! L ow! L
Application
Driving ports
Driven ports
For configuring
e:
for thei r purpos
e p o r t s
e th
We nam g_something”. For using For notifying
in
“For_do ion
m u l t i p le funct
ave
rt can h
Each po Application
calls. For getting data
For admin
For configuring
Test
harness For using For notifying
Mocked
receivers
Application
For getting
data Test
database
For
admin’ing
For controlling something
Mocked
devices
startup
For
configuring
For
using For notifying
GUI 1 actual
receivers
Application
For getting
data Production
GUI 2
database
For
admin’ing
For controlling
actual
devices
Tests
Other App(s)
Weather Email
For Warning For getting
admin’ing subscriber data
Tests System Test database
HTTP access
Development Sequence:
tests + mocks first
#1
Mock database
Tests
#2
For driving
the app For getting
data
production driver
App
Production database
#3
#4
A B A B
Useful for defining a public API Useful for decoupling a component from
its receivers
Driving actor
or adapter App provided i/f App App required i/f
App
Driven actor
Driven actor
or adapter
or adapter
class TaxCalculator {
private ForGettingTaxRates taxRateRepository;
class FixedTaxRateRepository
public TaxCalculator(ForGettingTaxRates taxRateRepository) { implements ForGettingTaxRates {
this.taxRateRepository = taxRateRepository; public double taxRate(double amount) {
} return 0.15; }
}
public double taxOn(double amount) {
return amount * taxRateRepository. taxRate( amount );
}
}
Car web ui
Driver adapter
For
tests in Cucumber parking
cars For obtaining
rates Test Double
For configuring
BlueZone
File adapter
Blue
tests in TestNG
Zone For storing
tickets
Test Double
For DB adapter
Parking CLI checking
cars For paying
Inspector adapter
Test Double
Wallet Adapter
Adapters
configurator
configurator
mock repo A
App
repo B
repo C
set
tax rate
repository
tax test
Main or calculator tax rate repository
test case
get get
tax tax rate production
tax rate repository
get
test
set tax rate rate repository broker
tax rate repository
repository
broker production
tax rate repository broker
main or calculator
test case
get test
tax
tax rate repository
get
tax rate
repository for country A
Benefits
Costs
1. You must add an instance var to hold each driven actor, or get it every
time.
2. You must add a constructor parameter or a setter function for each
driven actor, or a call to the configurator to get it.
3. You must design and add a configurator.
4. (Type-checked languages) You must declare the “required” interfaces.
5. (Type-checked languages) You must add folder structure for the port
declarations.