Skip to content

Instantly share code, notes, and snippets.

@AntonStoeckl
AntonStoeckl / function_types.go
Created June 3, 2022 07:52
Example for Blog Post "Hexagonal Architecture: Structuring a project and the influence of granularity V2
# With function types instead of interfaces all ports are automatically fine-grained
type ForSelectingDecks func(command SelectDeckCommand) error
type ForUnselectingDecks func(command UnselectDeckCommand) error
@AntonStoeckl
AntonStoeckl / structure4-fine-grouped.txt
Created June 3, 2022 07:36
Example for Blog Post "Hexagonal Architecture: Structuring a project and the influence of granularity V2
game
├── hexagon
│ ├── deckselection
│ │ ├── integration_test.go # primary adapter
│ │ ├── select_deck_command_handler.go # primary port + hexagon impl.
│ │ ├── select_deck_command_handler_test.go # primary adapter (unit test)
│ │ ├── select_deck.go # aggregate logic
│ │ ├── select_deck_http_handler.go # primary adapter
│ │ ├── select_deck_test.go # unit test
│ │ ├── unselect_deck_command_handler.go # primary port + hexagon impl.
@AntonStoeckl
AntonStoeckl / structure3-fine.txt
Created June 3, 2022 07:35
Example for Blog Post "Hexagonal Architecture: Structuring a project and the influence of granularity V2
game
├── hexagon
│ ├── forenrollingplayers
│ │ ├── command_handler.go # hexagon impl.
│ │ ├── command_handler_test.go # primary adapter (unit test)
│ │ ├── enroll_player.go # aggregate logic
│ │ ├── enroll_player_test.go # unit test
│ │ ├── http_handler.go # primary adapter
│ │ └── integration_test.go # primary adapter
│ ├── forfinishingcards
@AntonStoeckl
AntonStoeckl / structure2-coarse-with-slicing.txt
Created June 3, 2022 07:35
Example for Blog Post "Hexagonal Architecture: Structuring a project and the influence of granularity V2
game
├── application
│ ├── card_play_command_handler.go # hexagon impl.
│ ├── deck_selection_command_handler.go # hexagon impl.
│ ├── for_enrolling_players.go # primary port
│ ├── for_playing_cards.go # primary port
│ ├── for_reading_active_players_projections.go # secondary port
│ ├── for_reading_deck_sets.go # secondary port
│ ├── for_selecting_decks.go # primary port
│ ├── for_storing_events.go # secondary port
@AntonStoeckl
AntonStoeckl / structure1-coarse.txt
Created June 3, 2022 07:34
Example for Blog Post "Hexagonal Architecture: Structuring a project and the influence of granularity V2
game
├── application
│ ├── deck_builder_command_handler.go # hexagon implementation
│ ├── for_building_deck_sets.go # primary port
│ ├── for_playing_the_game.go # primary port
│ ├── for_reading_active_players_projections.go # secondary port
│ ├── for_reading_deck_sets.go # secondary port
│ ├── for_storing_deck_sets.go # secondary port
│ ├── for_storing_events.go # secondary port
│ └── player_command_handler.go # hexagon implementation
@AntonStoeckl
AntonStoeckl / driven_ports.go
Created June 3, 2022 07:33
Example for Blog Post "Hexagonal Architecture: Structuring a project and the influence of granularity V2
##### the coarse-grained version #####
type ForStoringEvents interface {
CreateEventStream(streamID lib.StreamID, event lib.Event) error
AppendEventsToStream(
streamID lib.StreamID,
expectedRevision uint64,
recordedEvents ...lib.Event,
) error
ReadEventStream(streamID lib.StreamID) (lib.EventStream, error)
@AntonStoeckl
AntonStoeckl / driver_ports.go
Created June 3, 2022 07:33
Example for Blog Post "Hexagonal Architecture: Structuring a project and the influence of granularity V2
##### the coarse-grained version #####
type ForPlayingTheGame interface {
SelectDeck(command SelectDeckCommand) error
UnselectDeck(command UnselectDeckCommand) error
EnrollPlayer(command EnrollPlayerCommand) error
SignOutPlayer(command SignOutPlayerCommand) error
PurgeInactivePlayers(command PurgeInactivePlayersCommand) (count uint, err error)
FinishCard(command FinishCardCommand) error
RejectCard(command RejectCardCommand) error
@AntonStoeckl
AntonStoeckl / all_driven_ports.go
Created May 20, 2022 11:05
Example for Blog Post "Hexagonal Architecture: Structuring a project and the influence of granularity"
type ForCreatingEventStreams interface {
Create(streamID lib.StreamID, event lib.Event) error
}
type ForAppendingEventsToStreams interface {
Append(
streamID lib.StreamID,
expectedRevision uint64,
recordedEvents ...lib.Event,
) error
@AntonStoeckl
AntonStoeckl / structure4.txt
Created May 20, 2022 11:03
Example for Blog Post "Hexagonal Architecture: Structuring a project and the influence of granularity"
game
├── application
│   ├── commands.go # all commands
│   ├── commands_test.go # unit tests
│   ├── deck_selection_command_handler.go # driver port implementation
│   ├── deck_selection_command_handler_test.go # driver adapter
│   ├── driven_ports.go # all driven port definitions
│   ├── driver_ports.go # all driver port definitions
| └── # other use cases and more files skipped
├── domain
@AntonStoeckl
AntonStoeckl / structure3.txt
Last active May 20, 2022 11:29
Example for Blog Post "Hexagonal Architecture: Structuring a project and the influence of granularity"
game
├── application
│   ├── deckselection
│   │   ├── commands.go # all commands
│   │   ├── commands_test.go # unit tests
│   │   ├── integration_test.go # driver adapter
│   │   ├── command_handler.go # driver port definition and implementation
│   │   ├── command_handler_test.go # driver adapter
│   │   ├── http_handler.go # driver adapter
│   │   ├── select_deck.go # domain logic