14

聊聊Ports and Adapters architecture - SegmentFault 思否

 4 years ago
source link: https://segmentfault.com/a/1190000039413401
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

本文主要研究一下Ports and Adapters architecture

Ports and Adapters architecture

Ports and Adapters architecture,又叫Hexagonal architecture,其中ports层是六边形的边界,其中port又可以分为driver port及driven port,简单理解对应输入层及输出层;边界保护的是内部的app,其中app包括use cases或者叫做application services层以及domain层;adapter可以理解为将外部依赖进行适配,实现port层定义的接口

github.com/albertllousas/implementing-hexagonal-architecture

├── app
│   ├── domain
│   │   ├── Account.kt
│   │   ├── Ids.kt
│   │   ├── Transaction.kt
│   │   └── Transfer.kt
│   ├── port
│   │   ├── driven
│   │   │   ├── AccountBalanceChecker.kt
│   │   │   ├── AccountFinder.kt
│   │   │   └── Transactor.kt
│   │   └── driver
│   │       └── TransferMoney.kt
│   └── usecase
│       └── TransferMoneyUseCase.kt
└── infrastructure
    ├── adapter
    │   ├── driven
    │   │   ├── InMemoryAccounts.kt
    │   │   └── InMemoryTransactions.kt
    │   └── driver
    │       └── ktor
    │           └── TransferHttpRoutes.kt
    └── config
        ├── ApplicationModule.kt
        └── ApplicationRunner.kt

port层这里定义了driven及driver两大类的接口,然后adapter层对应driven及driver这两大类使用外部的服务进行实现;domain层定义了domain model以及相关领域方法;usecase或者是application service层则是编排

Ports and Adapters architecture,又叫Hexagonal architecture,其中ports层是六边形的边界,其中port又可以分为driver port及driven port,简单理解对应输入层及输出层;边界保护的是内部的app,其中app包括use cases或者叫做application services层以及domain层;adapter可以理解为将外部依赖进行适配,实现port层定义的接口。


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK