洋葱架构中的典型层是什么? [英] What are the typical layers in an onion architecture?

查看:20
本文介绍了洋葱架构中的典型层是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在研究领域驱动设计,并尝试将其应用于 WPF 项目.我看了一些教程视频,并阅读了很多文章,例如:

I am currently studying the domain driven design, and try to apply it for a WPF project. I watched some tutorial videos, and read many articles, like :

我理解对接口和控制反转的关注.我读到有一些循环层名称(用于表示知识领域的域/核心、用于持久性的基础设施、用于……我不明白的应用程序),但是它们会根据我阅读的文章而改变.有些甚至没有出现.

I understood the focus on interfaces and inversion of control. I read there were some recurrent layer names (domain/core for the representation of the sphere of knowledge, infrastructures for persistance, application for ... i don't understand), but they change, depending of articles I read. Some even do not appear.

是否有可能有一个所有层的列表,理论上,洋葱架构需要这些层来面对所有的需求和问题,以及他们的意图(他们包含什么样的代码,他们有什么样的需求?尝试实现,他们需要参考哪一层),好吗?

Would it be possible to have an list of all layers that, in theory, are required in an onion architecture to face all needs and problems, with their intent (what kind of code do they contain, what kind of need do they try to fulfill, which layer do they need to reference), please ?

推荐答案

完全同意 Hippoom 的回答.从那里开始是完美的.

Totally agree with Hippoom's answer. It is perfect to start from there.

现在,

我读到有一些循环层名称(域/核心用于知识领域的代表,基础设施坚持,申请……我不明白),但他们改变了,取决于我读过的文章.有些甚至没有出现.

I read there were some recurrent layer names (domain/core for the representation of the sphere of knowledge, infrastructures for persistance, application for ... i don't understand), but they change, depending of articles I read. Some even do not appear.

是的,关于应用程序中的层的决定取决于特定场景中的许多因素.这就像大学如何划分课程并制定课程.这取决于他们想要服务的能力/多样性、手头的需求和大学的目的.它在全球范围内的细节(命名和分区)非常不同,但核心和意图始终相同.

Yes, decision about layers in an application depends upon many factors in a particular scenario. It is like how a universities divide their programs and make curriculum. It depend upon the capacity/diversity they want to serve, the need in hand and the purpose of university. It is very different in details (naming and partitions) across the globe but the core and intent is always same.

同样,应用程序中的层取决于需求和范围.有时,架构师过去常常根据他们在组织中遵循的理念和惯例来定义层的名称.因此,有时意图和名称可能会有所不同.但是具有可销售、可维护和满足功能和非功能需求的代码理念在手,始终如一.

In the same way, Layers in an application depends upon the need and scope. Sometime architects used to define the name of layers as per their philosophy and convention followed in the organization. So sometime the intent and name may differ to some extent. But the code idea of having salable, maintainable and fulfilling the functional and non-functional requirements in hand, remains always same.

是否有可能有一个所有层的列表,理论上,在洋葱架构中需要面对所有需求和问题,与他们的意图(他们包含什么样的代码,什么样的他们是否需要尝试实现,他们需要参考哪一层),请?

Would it be possible to have an list of all layers that, in theory, are required in an onion architecture to face all needs and problems, with their intent (what kind of code do they contain, what kind of need do they try to fulfill, which layer do they need to reference), please ?

Hippoom 已经做得很好了,他也在镜头中描述了意图.
标准层在此处描述:http://jeffreypalermo.com/blog/the-onion-architecture-part-1/
正如我已经提到的,层可能会根据应用程序的需要而有所不同.

Hippoom did it very well already and he described the intent in shot also.
Standard Layers are described here: http://jeffreypalermo.com/blog/the-onion-architecture-part-1/
As I already mentioned layers may differ as per applications need.

希望对你有帮助.谢谢.

Hope it would help you. Thanks.

根据大卫在下面的第一条评论中包含的详细信息:

应用服务实现用例并调用域服务、域实体和基础设施服务以完成工作.它提供与外界(主要是 UI 层项目)的接口以完成某些功能.例如,UserService 是一个应用程序服务.UserService 可以提供检查用户身份验证和特定资源授权、管理员更改用户权限、禁止用户等功能.为了完成这些用例,它将使用来自较低层的 UserRepository 和 UserEntity.

Application services implement the use cases and make calls to the Domain Services and Domain Entities and Infrastructure Services in order to get the job done. It provides interfaces to outside world (mainly UI layer projects) to accomplish certain functionalities. For example, UserService is an application service. UserService may provide functionalities to check for authentication for user and authorization for particular resource, change privilege for a user by admin, ban the user etc. To accomplish these use cases, it would use UserRepository and UserEntity from lower layers.

域服务与应用程序无关;它们通过封装 CRUD(创建、读取、更新、删除)操作和数据访问,提供了一种确保域模型完整性的方法.他们通常在洋葱架构中有域对象的存储库和UoW 实现等.

Domain services are application-agnostic; they provide a means to ensure the integrity of the domain model by encapsulating CRUD (Create, Read, Update, Delete) operations and data access. They usually have Repositories of Domain objects and UoW implementation etc in Onion Architecture.

这篇关于洋葱架构中的典型层是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆