aws-samples / aws-samples/aws-lambda-hexagonal-architecture

Ports are not abstracting adaptors

未关闭
#2 0 条评论 9 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
159
派生
27
PR 合并指标
30 天内没有已合并 PR

描述

I used internally this sample for training with my team, and they got confused by the responsibility of ports. They struggled to understand the abstraction and to translate it to typescript. This issue is an attempt to make things more clear for developers new to hexagonal architecture.

I believe ports should enforce a contract between Domain logic and Adaptors, and protect changes to happen on domain logic when the implementation details present in Adaptors change.

Here the port is not only enforcing the contract but tied to the adaptor on itself.

for example, the Repository port is tied to the implementation of a DynamoDB table with a defined schema.

https://github.com/aws-samples/aws-lambda-hexagonal-architecture/blob/1e9ec9a4e05479533ac01018adadf8e544b3a156/hexagonal-architecture/ports/Repository.js#L6

If we happen to change the database schema (changing key names, moving to a single table design, etc..), the port is not protecting the Domain logic from the implementation detail in the Adaptor. Moving to a single table design will imply changing Adaptor/ports and domain logic.

If we were in a typed language, the port would be represented by an Interface, that defines the contract (Input/Output), and the adaptor would implement this interface (the contract).

贡献指南

打开贡献指南

调研方向

从 issue 中链接的第 6 行 ports/Repository.js 开始,追踪其 contract 如何与 DynamoDB schema 耦合。利用 issue 中关于 input/output contract 的讨论,评估 domain logic 与 adaptor 之间的边界;当 adaptor schema 的变更不再需要相应的 domain 变更时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, node.js
领域
backend, backend-api-design
Issue 类型
重构
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。